@@ -462,7 +462,7 @@ public function specifyTypesInCondition(
462462 $ parametersAcceptor instanceof ParametersAcceptorWithPhpDocs ? $ parametersAcceptor ->getCallSiteVarianceMap () : TemplateTypeVarianceMap::createEmpty (),
463463 TemplateTypeVariance::createInvariant (),
464464 ));
465- $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ expr , $ asserts , $ parametersAcceptor , $ scope );
465+ $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ rootExpr , $ expr , $ asserts , $ parametersAcceptor , $ scope );
466466 if ($ specifiedTypes !== null ) {
467467 return $ specifiedTypes ;
468468 }
@@ -510,7 +510,7 @@ public function specifyTypesInCondition(
510510 $ parametersAcceptor instanceof ParametersAcceptorWithPhpDocs ? $ parametersAcceptor ->getCallSiteVarianceMap () : TemplateTypeVarianceMap::createEmpty (),
511511 TemplateTypeVariance::createInvariant (),
512512 ));
513- $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ expr , $ asserts , $ parametersAcceptor , $ scope );
513+ $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ rootExpr , $ expr , $ asserts , $ parametersAcceptor , $ scope );
514514 if ($ specifiedTypes !== null ) {
515515 return $ specifiedTypes ;
516516 }
@@ -563,7 +563,7 @@ public function specifyTypesInCondition(
563563 $ parametersAcceptor instanceof ParametersAcceptorWithPhpDocs ? $ parametersAcceptor ->getCallSiteVarianceMap () : TemplateTypeVarianceMap::createEmpty (),
564564 TemplateTypeVariance::createInvariant (),
565565 ));
566- $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ expr , $ asserts , $ parametersAcceptor , $ scope );
566+ $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ rootExpr , $ expr , $ asserts , $ parametersAcceptor , $ scope );
567567 if ($ specifiedTypes !== null ) {
568568 return $ specifiedTypes ;
569569 }
@@ -922,7 +922,7 @@ public function specifyTypesInCondition(
922922 TemplateTypeVariance::createInvariant (),
923923 ));
924924
925- $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ expr , $ asserts , $ parametersAcceptor , $ scope );
925+ $ specifiedTypes = $ this ->specifyTypesFromAsserts ($ context , $ rootExpr , $ expr , $ asserts , $ parametersAcceptor , $ scope );
926926
927927 if ($ specifiedTypes !== null ) {
928928 return $ specifiedTypes ;
@@ -1293,7 +1293,7 @@ public function getConditionalSpecifiedTypes(
12931293 return $ specifiedTypes ;
12941294 }
12951295
1296- private function specifyTypesFromAsserts (TypeSpecifierContext $ context , Expr \CallLike $ call , Assertions $ assertions , ParametersAcceptor $ parametersAcceptor , Scope $ scope ): ?SpecifiedTypes
1296+ private function specifyTypesFromAsserts (TypeSpecifierContext $ context , ? Expr $ rootExpr , Expr \CallLike $ call , Assertions $ assertions , ParametersAcceptor $ parametersAcceptor , Scope $ scope ): ?SpecifiedTypes
12971297 {
12981298 if ($ context ->null ()) {
12991299 $ asserts = $ assertions ->getAsserts ();
@@ -1334,8 +1334,7 @@ private function specifyTypesFromAsserts(TypeSpecifierContext $context, Expr\Cal
13341334 $ argsMap ['this ' ] = [$ call ->var ];
13351335 }
13361336
1337- /** @var SpecifiedTypes|null $types */
1338- $ types = null ;
1337+ $ types = $ this ->handleDefaultTruthyOrFalseyContext ($ context , $ rootExpr , $ call , $ scope );
13391338
13401339 foreach ($ asserts as $ assert ) {
13411340 foreach ($ argsMap [substr ($ assert ->getParameter ()->getParameterName (), 1 )] ?? [] as $ parameterExpr ) {
@@ -1378,7 +1377,7 @@ static function (Type $type, callable $traverse) use ($templateTypeMap, &$contai
13781377 $ scope ,
13791378 $ containsUnresolvedTemplate || $ assert ->isEquality () ? $ call : null ,
13801379 );
1381- $ types = $ types !== null ? $ types ->unionWith ($ newTypes ) : $ newTypes ;
1380+ $ types = $ types ->unionWith ($ newTypes );
13821381
13831382 if (!$ context ->null () || !$ assertedType instanceof ConstantBooleanType) {
13841383 continue ;
0 commit comments