@@ -220,7 +220,7 @@ public function __construct(
220220 private bool $ declareStrictTypes = false ,
221221 private PhpFunctionFromParserNodeReflection |null $ function = null ,
222222 ?string $ namespace = null ,
223- protected array $ expressionTypes = [],
223+ public array $ expressionTypes = [],
224224 protected array $ nativeExpressionTypes = [],
225225 protected array $ conditionalExpressions = [],
226226 protected array $ inClosureBindScopeClasses = [],
@@ -1005,7 +1005,7 @@ public function getScopeNativeType(Expr $expr): Type
10051005 return $ this ->getNativeType ($ expr );
10061006 }
10071007
1008- private function getNodeKey (Expr $ node ): string
1008+ public function getNodeKey (Expr $ node ): string
10091009 {
10101010 // perf optimize for the most common path
10111011 if ($ node instanceof Variable && !$ node ->name instanceof Expr) {
@@ -1096,44 +1096,6 @@ private function resolveType(string $exprString, Expr $node): Type
10961096 return new NullType ();
10971097 }
10981098
1099- if ($ node instanceof ConstFetch) {
1100- $ constName = (string ) $ node ->name ;
1101- $ loweredConstName = strtolower ($ constName );
1102- if ($ loweredConstName === 'true ' ) {
1103- return new ConstantBooleanType (true );
1104- } elseif ($ loweredConstName === 'false ' ) {
1105- return new ConstantBooleanType (false );
1106- } elseif ($ loweredConstName === 'null ' ) {
1107- return new NullType ();
1108- }
1109-
1110- $ namespacedName = null ;
1111- if (!$ node ->name ->isFullyQualified () && $ this ->getNamespace () !== null ) {
1112- $ namespacedName = new FullyQualified ([$ this ->getNamespace (), $ node ->name ->toString ()]);
1113- }
1114- $ globalName = new FullyQualified ($ node ->name ->toString ());
1115-
1116- foreach ([$ namespacedName , $ globalName ] as $ name ) {
1117- if ($ name === null ) {
1118- continue ;
1119- }
1120- $ constFetch = new ConstFetch ($ name );
1121- if ($ this ->hasExpressionType ($ constFetch )->yes ()) {
1122- return $ this ->constantResolver ->resolveConstantType (
1123- $ name ->toString (),
1124- $ this ->expressionTypes [$ this ->getNodeKey ($ constFetch )]->getType (),
1125- );
1126- }
1127- }
1128-
1129- $ constantType = $ this ->constantResolver ->resolveConstant ($ node ->name , $ this );
1130- if ($ constantType !== null ) {
1131- return $ constantType ;
1132- }
1133-
1134- return new ErrorType ();
1135- }
1136-
11371099 if ($ node instanceof MethodCall) {
11381100 $ callType = $ this ->getMethodCallType ($ node );
11391101 if ($ callType !== null ) {
0 commit comments