@@ -1313,6 +1313,17 @@ private function specifyTypesFromAsserts(TypeSpecifierContext $context, Expr\Cal
1313
1313
continue ;
1314
1314
}
1315
1315
1316
+ $ assertedType = TypeTraverser::map ($ assert ->getType (), static function (Type $ type , callable $ traverse ) use ($ argsMap , $ scope ): Type {
1317
+ if ($ type instanceof ConditionalTypeForParameter) {
1318
+ $ parameterName = substr ($ type ->getParameterName (), 1 );
1319
+ if (array_key_exists ($ parameterName , $ argsMap )) {
1320
+ $ type = $ type ->toConditional ($ scope ->getType ($ argsMap [$ parameterName ]));
1321
+ }
1322
+ }
1323
+
1324
+ return $ traverse ($ type );
1325
+ });
1326
+
1316
1327
$ assertExpr = $ assert ->getParameter ()->getExpr ($ parameterExpr );
1317
1328
1318
1329
$ templateTypeMap = $ parametersAcceptor ->getResolvedTemplateTypeMap ();
@@ -1334,19 +1345,19 @@ static function (Type $type, callable $traverse) use ($templateTypeMap, &$contai
1334
1345
1335
1346
$ newTypes = $ this ->create (
1336
1347
$ assertExpr ,
1337
- $ assert -> getType () ,
1348
+ $ assertedType ,
1338
1349
$ assert ->isNegated () ? TypeSpecifierContext::createFalse () : TypeSpecifierContext::createTrue (),
1339
1350
false ,
1340
1351
$ scope ,
1341
1352
$ containsUnresolvedTemplate || $ assert ->isEquality () ? $ call : null ,
1342
1353
);
1343
1354
$ types = $ types !== null ? $ types ->unionWith ($ newTypes ) : $ newTypes ;
1344
1355
1345
- if (!$ context ->null () || !$ assert -> getType () instanceof ConstantBooleanType) {
1356
+ if (!$ context ->null () || !$ assertedType instanceof ConstantBooleanType) {
1346
1357
continue ;
1347
1358
}
1348
1359
1349
- $ subContext = $ assert -> getType () ->getValue () ? TypeSpecifierContext::createTrue () : TypeSpecifierContext::createFalse ();
1360
+ $ subContext = $ assertedType ->getValue () ? TypeSpecifierContext::createTrue () : TypeSpecifierContext::createFalse ();
1350
1361
if ($ assert ->isNegated ()) {
1351
1362
$ subContext = $ subContext ->negate ();
1352
1363
}
0 commit comments