-
Notifications
You must be signed in to change notification settings - Fork 477
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
Implement ArrayColumnRule #3706
base: 1.12.x
Are you sure you want to change the base?
Conversation
0ab86d3
to
9345415
Compare
@herndlm any opinions on the rule? only the last commit is important. commits 1-3 are pure refactorings, which could land as a separate previous PR, in case ondrej is fine with the approach in general btw: |
[$returnValueType, $iterableAtLeastOnce] = $this->arrayColumnHelper->getReturnValueType($arrayType, $columnKeyType, $scope); | ||
if ($returnValueType instanceof NeverType || $iterableAtLeastOnce->no()) { | ||
$errorBuilder = RuleErrorBuilder::message(sprintf( | ||
'Cannot access column %s on %s.', |
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 we will need a better message.. maybe mentioning array offsets or property access, but how to name it in unions of array/objects..?
maybe we can find a better generic message
d6812de
to
adb4d58
Compare
closes phpstan/phpstan#5101
closes phpstan/phpstan#12188
ArrayColumnRule re-uses the logic from the
array_column
return type extension and reports problems when the logic implies the result will be a never-type.there are more open problems with
array_column
and I would approach those after this PR got merged