Skip to content

[13.x] Convert File::types() from static to instance method#59247

Closed
AnnoyingTechnology wants to merge 2 commits intolaravel:13.xfrom
AnnoyingTechnology:fix/file-types-instance-method
Closed

[13.x] Convert File::types() from static to instance method#59247
AnnoyingTechnology wants to merge 2 commits intolaravel:13.xfrom
AnnoyingTechnology:fix/file-types-instance-method

Conversation

@AnnoyingTechnology
Copy link
Copy Markdown

File::types() is a static factory that returns new static(). When called in a fluent chain
(File::image()->max(1)->types(['jpg'])), PHP invokes the static method and returns a fresh
object, silently discarding all prior configuration.

This makes types() an instance method returning $this, consistent with extensions() and the
rest of the fluent builder API.

Breaking change: File::types([...]) as a static entry point no longer works. Replace with
Rule::file()->types([...])

Fixes #59242
Fixes #59242

File::types() was a static factory that returned new static(), silently
discarding all prior chain configuration (max, dimensions, allowSvg,
etc.) when called on an existing instance. This makes types() an
instance method returning $this, consistent with extensions() and the
rest of the fluent builder API.

Fixes laravel#59242
@taylorotwell
Copy link
Copy Markdown
Member

Breaking change day of release.

@AnnoyingTechnology
Copy link
Copy Markdown
Author

AnnoyingTechnology commented Mar 17, 2026

When should this be re-open @taylorotwell ?

Is there a way to document this silent validation bypass in the meantime ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants