phpstan: Incorrect variable always exists
Summary of a problem or a feature request
PHPStan incorrectly reports that a variable always exists in some cases.
Code snippet that reproduces the problem
https://phpstan.org/r/b0e37609338d0c49645295f039a0e73d
Expected output
PHPStan complains that Variable $handle in isset() always exists and is not nullable.. However, https://3v4l.org/nUfFW shows the actual output is ko, which means the isset gets evaluated to false.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (15 by maintainers)
BTW I implemented
assertVariableCertainty: https://github.com/phpstan/phpstan-src/commit/1567d0ff6f2e2c3959f5b8b543d84d9e57051a03You can try to do it. You’ll see which test cases will fail and we’ll probably have to decide which behaviour is better/less annoying 😃
Fixed: https://github.com/phpstan/phpstan/commit/0da95fcfb5c925ac42346b58713a4f68e834a036
@lookyman Please submit this as a new issue next time, this makes issue management harder 😊 I will look into it.