Skip to content

Apply a rule like MatchExpressionNode to a method which accepts a condition as argument #10762

Answered by ondrejmirtes
mglaman asked this question in Support
Discussion options

You must be logged in to vote

So basically you want to make sure that the method is not called with something PHPStan already knows is truthy/falsy?

You can write a rule for StaticCall and check the first argument type:

$bool = $type->toBoolean();
$report = $bool->isTrue()->or($bool->isFalse())->yes();

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mglaman
Comment options

@ondrejmirtes
Comment options

Answer selected by mglaman
@mglaman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants