Feature request
Example code
https://phpstan.org/r/5959b487-8706-43d3-902a-138dd8c00b48
function sayHello(): void
{
echo 'Hello, ' . ($name ?? 'anonymous') . '!';
}
Description
The code snippet above is valid PHP and phpstan does not complain about it.
However, we can see that the variable $name here will definitely be undefined. Because of that, the expression will always evaluate to the default value. This is a potential source of errors, e.g. when there is a type in the variable name.
It would be awesome if phpstan could detect and report cases like that.
Feature request
Example code
https://phpstan.org/r/5959b487-8706-43d3-902a-138dd8c00b48
Description
The code snippet above is valid PHP and phpstan does not complain about it.
However, we can see that the variable
$namehere will definitely be undefined. Because of that, the expression will always evaluate to the default value. This is a potential source of errors, e.g. when there is a type in the variable name.It would be awesome if phpstan could detect and report cases like that.