Fix ImpossibleCheckTypeFunctionCallRule for is_subclass and is_a#3788
Merged
ondrejmirtes merged 3 commits intophpstan:1.12.xfrom May 5, 2025
Merged
Fix ImpossibleCheckTypeFunctionCallRule for is_subclass and is_a#3788ondrejmirtes merged 3 commits intophpstan:1.12.xfrom
is_subclass and is_a#3788ondrejmirtes merged 3 commits intophpstan:1.12.xfrom
Conversation
Contributor
|
I don't know if this PR would fix this, but I just upgraded to the latest PHPStan version and this new error popped up: for this code : #[Override]
public function supports(Model $model): bool
{
$type = $model->getType();
if ('object' !== $type->getBuiltinType()) {
return false;
}
$class = $type->getClassName();
if (null === $class || !class_exists($class)) {
return false;
}
$reflection = new ReflectionClass($class);
return $reflection->isSubclassOf(ListQuery::class) ? ... : ...;Should I open a separate bug? |
Member
|
@gnutix That is unrelated, and most likely a consequence of phpstan/phpstan#12459 |
Contributor
Author
|
Friendly ping @ondrejmirtes ; this PR is ready to be reviewed :) |
Member
|
Thank you! |
This was referenced May 5, 2025
Call to function
is_subclass_of() is reported as always being evaluated as true
phpstan/phpstan#8464
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improved strategy for #3404
The main idea is that
always trueerror can always be reported if the second param is a Constant class-string (or union of them).I included a non regression test from
#3404 (comment)
Closes phpstan/phpstan#3979
Closes phpstan/phpstan#8464