Skip to content

Right side of && is always true #4477

Discussion options

You must be logged in to vote

I think you're hitting the "dependent variables" feature that was added in 0.12.64: https://github.com/phpstan/phpstan/releases/tag/0.12.64

In your example, $varB will only ever be true when $varA is true. So if you check for truthiness of $varA, it means that you don't have to check for $varB because it can only ever be true too.

So having if ($varA) is sufficient. See: https://phpstan.org/r/cd4aa27a-7bf4-4f97-adc6-2f60246da018

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@haringsrob
Comment options

Answer selected by ondrejmirtes
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