-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Array typehints for Update methods #54352
Array typehints for Update methods #54352
Conversation
@@ -3840,7 +3840,7 @@ public function insertOrIgnoreUsing(array $columns, $query) | |||
/** | |||
* Update records in the database. | |||
* | |||
* @param array $values | |||
* @param array<string, mixed> $values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mixed
might be improved:
* @param array<string, mixed> $values | |
* @param array<string, \Illuminate\Database\Query\Builder|\Illuminate\Support\Collection|\UnitEnum|mixed> $values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, that feels like a more involved change than I was planning to make here (although I'm happy to implement it if desired by the maintainers).
I'm also not sure of the value of adding other types, in a union with mixed
? With it being the top type, I believe X|mixed
is equivalent to mixed
(for any X
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would like to get rid of the mixed altogether but at a quick glance, I didn't know what were possible types for the default
match
case. I just thought: What good is it to retroactively add doc block types and then still end up with mixed
? That might not be your fault, but I would be trying to avoid that to achieve an actually improved typing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that mixed is enough here for now.
I think it's fine for now. |
Hey, this PR aims to improve static analysis around passing numerically keyed arrays to "update" methods. The following situations will now be reported by static analysers:
These are already stubbed in Larastan, but this change will benefit those who do not use it.