-
Notifications
You must be signed in to change notification settings - Fork 551
Respect phpstan level in ParameterCastableToNumberRule #4873
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
bb32d03 to
5dbfff4
Compare
| $scope, | ||
| $parameter->value, | ||
| '', | ||
| static fn (Type $type): bool => $type->isArray()->yes() && !$castFn($type->getIterableValueType()) instanceof ErrorType, |
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.
The following change follows the same idea than https://github.com/phpstan/phpstan-src/pull/4166/changes for instance.
&& and || doesn't work always very well in UnionTypeCriteriaCallback it's sometimes better to split the check into multiple findTypeToCheck calls.
Here this allows to transform the iterable value type $type->getIterableValueType() into a StrictMixed when it's a Mixed for instance or array<mixed> is never reported at any level.
| $castFn = $this->phpVersion->supportsObjectsInArraySumProduct() | ||
| ? static fn (Type $t) => $t->toNumber() | ||
| : static fn (Type $t) => !$t->isObject()->no() ? new ErrorType() : $t->toNumber(); | ||
| : static fn (Type $t) => $t instanceof MixedType || $t->isObject()->no() ? $t->toNumber() : new ErrorType(); |
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.
MixedType should not be transform automatically to ErrorType, we will rely on the ruleLevelHelper inside the parameterCastableToStringCheck to decide.
|
This pull request has been marked as ready for review. |
|
Some errors are new on Compile PHAR / integration-tests / PMMP Tests (pull_request) I need to check Edit: This is expected ! They are using the level 9 |
staabm
left a comment
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 would prefer @ondrejmirtes reviewing this one, as my experience with RuleLevelHelper is very limited
Complete #4867