Skip to content

[12.x] Clean up redundant type hints in docblocks #56690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

amirhshokri
Copy link
Contributor

continuation of #56411

@taylorotwell taylorotwell merged commit 66d6f8f into laravel:12.x Aug 20, 2025
62 checks passed
@amirhshokri amirhshokri deleted the 12.x-clean-up-redundant-type-hints branch August 20, 2025 14:10
@browner12
Copy link
Contributor

gotta say this feels like a step in the wrong direction.

  • Why did we leave in union types when the non-mixed type was something like \Illuminate\...? There are 11 instances of this in the current PR. If we're going to say custom classes have value when combined with mixed, how can we say things like array do not?

I had another point, but as I dug into it, it looks like there've been some commits/reversions in the past couple of weeks regarding typing, so I'm not sure if my point holds anymore.

All in all, what I'd like to see is us move more towards explicit typing, even if that means somewhat long union types. I also don't mind the array|mixed types, even though I accept the changes you've made are technically correct. The way I read array|mixed is "there's a pretty high chance you should be giving me an array, but technically I can accept anything".

What I'd really love to see is actual strict parameter and return typing, but that's a discussion for another day...

@amirhshokri
Copy link
Contributor Author

amirhshokri commented Aug 20, 2025

Thanks for your feedback and for the time you took to review it @browner12

  • Why did we leave in union types when the non-mixed type was something like \Illuminate\...? There are 11 instances of this in the current PR. If we're going to say custom classes have value when combined with mixed, how can we say things like array do not?

I think it’s because array is one of PHP’s built-in data types, which is already covered by mixed. But this doesn’t apply to things like Laravel Collections.

  • What I'd really love to see is actual strict parameter and return typing, but that's a discussion for another day...

I completely agree, and I’m also strict about this when I develop something. However, PRs in open source are a different matter, and in this case we also have the mixed type, which can’t be easily removed.

@browner12
Copy link
Contributor

unless I'm mistaken, mixed also includes custom classes like \Collection.

https://www.php.net/manual/en/language.types.mixed.php

@amirhshokri
Copy link
Contributor Author

amirhshokri commented Aug 20, 2025

It’s an interesting point to examine. However, I think a collection is an instance of the \Collection class, which can contain a set of mixed items.

@browner12

@shaedrich
Copy link
Contributor

shaedrich commented Aug 21, 2025

I would assume, Collection is only included in mixed when it's used without a generic, narrowing it down.

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.

4 participants