Skip to content

[11.x] Revert faulty change to EnumeratesValues::ensure() doc block#54919

Merged
taylorotwell merged 1 commit into
laravel:11.xfrom
axlon:fix-ensure-docs
Mar 6, 2025
Merged

[11.x] Revert faulty change to EnumeratesValues::ensure() doc block#54919
taylorotwell merged 1 commit into
laravel:11.xfrom
axlon:fix-ensure-docs

Conversation

@axlon

@axlon axlon commented Mar 6, 2025

Copy link
Copy Markdown
Contributor

This PR partially reverts #54840, specifically one commit which breaks PHPStan type inference.

Explanation:

It seems that there was some confusion and these types were shortened to scalar as if the doc blocks said "any string, float, int or bool is allowed" which is a wrong assumption. The doc blocks in fact said "these exact string values are allowed". By changing these constant strings to scalar PHPStan will merge the parameter types (after all a class-string is also a scalar) and the template type becomes unresolvable.

E.g. $collection->ensure(Foo::class) no longer works after the change to scalar (edit: it still works, but PHPStan can't resolve the type)

@cosmastech

Copy link
Copy Markdown
Contributor

Thanks for doing this. Was just bumping Laravel versions on some apps and got this exact error.

@taylorotwell taylorotwell merged commit 69a7dbd into laravel:11.x Mar 6, 2025
@axlon axlon deleted the fix-ensure-docs branch March 4, 2026 19:25
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.

3 participants