Skip to content

[13.x] Improve collection return types for methods that mutate - #61571

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
axlon:collection-this-out
Sep 13, 2026
Merged

taylorotwell merged 3 commits into
laravel:13.xfrom
axlon:collection-this-out

Conversation

@axlon

@axlon axlon commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

PHPStan 2.2.14 ships a bugfix that fixes that PHPStan could not understand (T of array-key)|int. Since this is now fixed some Collection methods that mutate the collection directly can have their types improved.

Before:

collect(['foo' => 'bar'])->push('baz'); // Collection<string, string>

After:

collect(['foo' => 'bar'])->push('baz'); // Collection<int|string, string>

@taylorotwell
taylorotwell merged commit 6b2357c into laravel:13.x Sep 13, 2026
56 checks passed
@axlon
axlon deleted the collection-this-out branch September 14, 2026 19:49
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