1010use PHPStan \Reflection \MethodReflection ;
1111use PHPStan \Reflection \ParameterReflection ;
1212use PHPStan \Type \Type ;
13- use function count ;
14- use function defined ;
1513
1614final class FiberScope extends MutatingScope
1715{
1816
19- private const EXPR_TYPE_ATTRIBUTE_NAME = 'fnsrType ' ;
20-
21- private const EXPR_NATIVE_TYPE_ATTRIBUTE_NAME = 'fnsrNativeType ' ;
22-
2317 /** @var Expr[] */
2418 private array $ truthyValueExprs = [];
2519
@@ -62,27 +56,13 @@ public function toMutatingScope(): MutatingScope
6256 /** @api */
6357 public function getType (Expr $ node ): Type
6458 {
65- $ shouldCache = defined ('__PHPSTAN_RUNNING__ ' ) && !$ this ->isInTrait () && count ($ this ->truthyValueExprs ) === 0 && count ($ this ->falseyValueExprs ) === 0 && !$ this ->nativeTypesPromoted ;
66- if ($ shouldCache ) {
67- $ cachedType = $ node ->getAttribute (self ::EXPR_TYPE_ATTRIBUTE_NAME );
68- if ($ cachedType !== null ) {
69- return $ cachedType ;
70- }
71- }
72-
7359 /** @var Scope $beforeScope */
7460 $ beforeScope = Fiber::suspend (
7561 new BeforeScopeForExprRequest ($ node , $ this ),
7662 );
7763
7864 $ scope = $ this ->preprocessScope ($ beforeScope ->toMutatingScope ());
79- $ type = $ scope ->getType ($ node );
80-
81- if ($ shouldCache ) {
82- $ node ->setAttribute (self ::EXPR_TYPE_ATTRIBUTE_NAME , $ type );
83- }
84-
85- return $ type ;
65+ return $ scope ->getType ($ node );
8666 }
8767
8868 public function getScopeType (Expr $ expr ): Type
@@ -98,27 +78,13 @@ public function getScopeNativeType(Expr $expr): Type
9878 /** @api */
9979 public function getNativeType (Expr $ expr ): Type
10080 {
101- $ shouldCache = defined ('__PHPSTAN_RUNNING__ ' ) && !$ this ->isInTrait () && count ($ this ->truthyValueExprs ) === 0 && count ($ this ->falseyValueExprs ) === 0 && !$ this ->nativeTypesPromoted ;
102- if ($ shouldCache ) {
103- $ cachedType = $ expr ->getAttribute (self ::EXPR_NATIVE_TYPE_ATTRIBUTE_NAME );
104- if ($ cachedType !== null ) {
105- return $ cachedType ;
106- }
107- }
108-
10981 /** @var Scope $beforeScope */
11082 $ beforeScope = Fiber::suspend (
11183 new BeforeScopeForExprRequest ($ expr , $ this ),
11284 );
11385
11486 $ scope = $ this ->preprocessScope ($ beforeScope ->toMutatingScope ());
115- $ type = $ scope ->getNativeType ($ expr );
116-
117- if ($ shouldCache ) {
118- $ expr ->setAttribute (self ::EXPR_NATIVE_TYPE_ATTRIBUTE_NAME , $ type );
119- }
120-
121- return $ type ;
87+ return $ scope ->getNativeType ($ expr );
12288 }
12389
12490 public function getKeepVoidType (Expr $ node ): Type
0 commit comments