@@ -333,21 +333,6 @@ public function specifyTypesInCondition(
333
333
}
334
334
}
335
335
336
- if (
337
- !$ context ->null ()
338
- && $ expr ->right instanceof FuncCall
339
- && count ($ expr ->right ->getArgs ()) >= 3
340
- && $ expr ->right ->name instanceof Name
341
- && in_array (strtolower ((string ) $ expr ->right ->name ), ['preg_match ' ], true )
342
- && IntegerRangeType::fromInterval (0 , null )->isSuperTypeOf ($ leftType )->yes ()
343
- ) {
344
- return $ this ->specifyTypesInCondition (
345
- $ scope ,
346
- new Expr \BinaryOp \NotIdentical ($ expr ->right , new ConstFetch (new Name ('false ' ))),
347
- $ context ,
348
- )->setRootExpr ($ expr );
349
- }
350
-
351
336
if (
352
337
!$ context ->null ()
353
338
&& $ expr ->right instanceof FuncCall
@@ -468,6 +453,27 @@ public function specifyTypesInCondition(
468
453
}
469
454
}
470
455
456
+ if (
457
+ !$ context ->null ()
458
+ && $ expr ->left instanceof Node \Scalar
459
+ && $ expr ->right instanceof Expr \FuncCall
460
+ && $ expr ->right ->name instanceof Name
461
+ && in_array (strtolower ((string ) $ expr ->right ->name ), ['preg_match ' ], true )
462
+ ) {
463
+ if (!$ scope instanceof MutatingScope) {
464
+ throw new ShouldNotHappenException ();
465
+ }
466
+ $ newScope = $ scope ->filterBySpecifiedTypes ($ result );
467
+ $ callType = $ newScope ->getType ($ expr ->right );
468
+ $ newContext = $ context ->newWithReturnType ($ callType );
469
+
470
+ $ result = $ result ->unionWith ($ this ->specifyTypesInCondition (
471
+ $ scope ,
472
+ $ expr ->right ,
473
+ $ newContext ,
474
+ )->setRootExpr ($ expr ));
475
+ }
476
+
471
477
return $ result ;
472
478
473
479
} elseif ($ expr instanceof Node \Expr \BinaryOp \Greater) {
0 commit comments