-
-
Notifications
You must be signed in to change notification settings - Fork 947
Include previous check on null safe operator property on object #6991
Copy link
Copy link
Closed
Labels
Milestone
Description
Feature request
Currently phpstan would throw an error when trying access a property of an object, which was previously checked via a null safe operator on another property of it.
I'm using something like this code from Symfony Request:
$currentRequest = $this->requestStack->getCurrentRequest();
/** @var string|null $currentRouteName */
$currentRouteName = $currentRequest?->attributes->get('_route');
if (!$currentRouteName) {
return [];
}
// later ...
// in the next line $currentRequest can not be null because of the `if (!$currentRouteName) {` check
$routeAttributes = $currentRequest->attributes->get('_route_params', []); A simpler example:
https://phpstan.org/r/af51a08d-960d-4001-a1a7-21f991ea83b2
Reactions are currently unavailable