@@ -931,7 +931,12 @@ private function resolveType(string $exprString, Expr $node): Type
931931 return new NonAcceptingNeverType ();
932932 }
933933
934- if (!$ node instanceof Variable && $ this ->hasExpressionType ($ node )->yes ()) {
934+ if (
935+ !$ node instanceof Variable
936+ && !$ node instanceof Expr \Closure
937+ && !$ node instanceof Expr \ArrowFunction
938+ && $ this ->hasExpressionType ($ node )->yes ()
939+ ) {
935940 return $ this ->expressionTypes [$ exprString ]->getType ();
936941 }
937942
@@ -3575,7 +3580,7 @@ public function enterAnonymousFunction(
35753580 ?array $ callableParameters ,
35763581 ): self
35773582 {
3578- $ anonymousFunctionReflection = $ this ->getType ( $ closure );
3583+ $ anonymousFunctionReflection = $ this ->resolveType ( ' __phpstanClosure ' , $ closure );
35793584 if (!$ anonymousFunctionReflection instanceof ClosureType) {
35803585 throw new ShouldNotHappenException ();
35813586 }
@@ -3771,7 +3776,7 @@ private function invalidateStaticExpressions(array $expressionTypes): array
37713776 */
37723777 public function enterArrowFunction (Expr \ArrowFunction $ arrowFunction , ?array $ callableParameters ): self
37733778 {
3774- $ anonymousFunctionReflection = $ this ->getType ( $ arrowFunction );
3779+ $ anonymousFunctionReflection = $ this ->resolveType ( ' __phpStanArrowFn ' , $ arrowFunction );
37753780 if (!$ anonymousFunctionReflection instanceof ClosureType) {
37763781 throw new ShouldNotHappenException ();
37773782 }
0 commit comments