-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels