55use Generator ;
66use PhpParser \Node \Expr ;
77use PhpParser \Node \Expr \Cast \Int_ ;
8+ use PhpParser \Node \Scalar \LNumber ;
9+ use PhpParser \Node \Scalar \String_ ;
810use PhpParser \Node \Stmt ;
911use PHPStan \Analyser \ExpressionContext ;
1012use PHPStan \Analyser \Generator \ExprAnalysisRequest ;
1113use PHPStan \Analyser \Generator \ExprAnalysisResult ;
1214use PHPStan \Analyser \Generator \ExprHandler ;
1315use PHPStan \Analyser \Generator \GeneratorScope ;
16+ use PHPStan \Analyser \Generator \NoopNodeCallback ;
1417use PHPStan \Analyser \SpecifiedTypes ;
1518use PHPStan \DependencyInjection \AutowiredService ;
1619
@@ -35,6 +38,7 @@ public function analyseExpr(
3538 ): Generator
3639 {
3740 $ exprResult = yield new ExprAnalysisRequest ($ stmt , $ expr ->expr , $ scope , $ context ->enterDeep (), $ alternativeNodeCallback );
41+ $ specifiedExprResult = yield new ExprAnalysisRequest ($ stmt , new Expr \BinaryOp \Equal ($ expr ->expr , new LNumber (0 )), $ scope , $ context ->enterDeep (), new NoopNodeCallback ());
3842
3943 return new ExprAnalysisResult (
4044 $ exprResult ->type ->toInteger (),
@@ -44,9 +48,9 @@ public function analyseExpr(
4448 isAlwaysTerminating: false ,
4549 throwPoints: [],
4650 impurePoints: [],
47- specifiedTruthyTypes: new SpecifiedTypes () ,
48- specifiedFalseyTypes: new SpecifiedTypes () ,
49- specifiedNullTypes: new SpecifiedTypes () ,
51+ specifiedTruthyTypes: $ specifiedExprResult -> specifiedTruthyTypes ,
52+ specifiedFalseyTypes: $ specifiedExprResult -> specifiedFalseyTypes ,
53+ specifiedNullTypes: $ specifiedExprResult -> specifiedNullTypes ,
5054 );
5155 }
5256
0 commit comments