@@ -797,6 +797,19 @@ public function getAnonymousFunctionReturnType(): ?Type
797797 /** @api */
798798 public function getType (Expr $ node ): Type
799799 {
800+ if ($ node instanceof Node \Scalar \Int_) {
801+ return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
802+ } elseif ($ node instanceof String_) {
803+ return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
804+ } elseif ($ node instanceof Node \Scalar \Float_) {
805+ return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
806+ } elseif ($ node instanceof ConstFetch) {
807+ $ loweredConstName = strtolower ($ node ->name ->toString ());
808+ if (in_array ($ loweredConstName , ['true ' , 'false ' , 'null ' ], true )) {
809+ return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
810+ }
811+ }
812+
800813 if ($ node instanceof GetIterableKeyTypeExpr) {
801814 return $ this ->getIterableKeyType ($ this ->getType ($ node ->getExpr ()));
802815 }
@@ -1295,11 +1308,7 @@ private function resolveType(string $exprString, Expr $node): Type
12951308 });
12961309 }
12971310
1298- if ($ node instanceof Node \Scalar \Int_) {
1299- return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
1300- } elseif ($ node instanceof String_) {
1301- return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
1302- } elseif ($ node instanceof Node \Scalar \InterpolatedString) {
1311+ if ($ node instanceof Node \Scalar \InterpolatedString) {
13031312 $ resultType = null ;
13041313 foreach ($ node ->parts as $ part ) {
13051314 if ($ part instanceof InterpolatedStringPart) {
@@ -1316,8 +1325,6 @@ private function resolveType(string $exprString, Expr $node): Type
13161325 }
13171326
13181327 return $ resultType ?? new ConstantStringType ('' );
1319- } elseif ($ node instanceof Node \Scalar \Float_) {
1320- return $ this ->initializerExprTypeResolver ->getType ($ node , InitializerExprContext::fromScope ($ this ));
13211328 } elseif ($ node instanceof Expr \CallLike && $ node ->isFirstClassCallable ()) {
13221329 if ($ node instanceof FuncCall && $ node ->name instanceof Expr) {
13231330 $ callableType = $ this ->getType ($ node ->name );
0 commit comments