-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1950Labels
Milestone
Description
Bug report
This is the example of conditionally defined variables from:
https://phpstan.org/writing-php-code/solving-undefined-variables
Despite the documentation saying that PHPStan understands this case, it doesn't actually appear to. The snippet itself has the problem that $foo is undefined but if it's set to a indeterminate value than $var will be flagged as undefined (if the level is at least 1). Note that if $foo is determined to be truthy then no error is produced.
Code snippet that reproduces the problem
https://phpstan.org/r/b720c0fb-d944-4ba4-9d9b-a0b3c81f55c1
Expected output
Expect that this is not flagged because var is defined any time it is not referenced.