-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Labels
Milestone
Description
Bug report
https://phpstan.org/r/d7f7272b-92ac-4497-a6b2-07c98e3df70e
<?php declare(strict_types = 1);
$test = random_int(0, 10);
if ($test > 5) {
$user = new stdClass;
$user->name = 'Thibaud';
}
echo $user->name ?? 'Default'; // Variable $user might not be defined.Expected output
There is no error in this code, PHP isset is working with nested attributes isset($abc->def->ghi) (https://www.php.net/manual/fr/function.isset.php#86313) and $var ?? $default is only a shortcut to isset($var) ? $var : $default.
brandonkelly