Skip to content

Commit dd8e601

Browse files
committed
MutatingScope - more micro-optimization
1 parent 775ac53 commit dd8e601

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/Analyser/MutatingScope.php

+36-6
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ public function pushInFunctionCall($reflection): self
23732373
$stack = $this->inFunctionCallsStack;
23742374
$stack[] = $reflection;
23752375

2376-
return $this->scopeFactory->create(
2376+
$scope = $this->scopeFactory->create(
23772377
$this->context,
23782378
$this->isDeclareStrictTypes(),
23792379
$this->constantTypes,
@@ -2392,14 +2392,19 @@ public function pushInFunctionCall($reflection): self
23922392
$this->afterExtractCall,
23932393
$this->parentScope,
23942394
);
2395+
$scope->resolvedTypes = $this->resolvedTypes;
2396+
$scope->truthyScopes = $this->truthyScopes;
2397+
$scope->falseyScopes = $this->falseyScopes;
2398+
2399+
return $scope;
23952400
}
23962401

23972402
public function popInFunctionCall(): self
23982403
{
23992404
$stack = $this->inFunctionCallsStack;
24002405
array_pop($stack);
24012406

2402-
return $this->scopeFactory->create(
2407+
$scope = $this->scopeFactory->create(
24032408
$this->context,
24042409
$this->isDeclareStrictTypes(),
24052410
$this->constantTypes,
@@ -2418,6 +2423,11 @@ public function popInFunctionCall(): self
24182423
$this->afterExtractCall,
24192424
$this->parentScope,
24202425
);
2426+
$scope->resolvedTypes = $this->resolvedTypes;
2427+
$scope->truthyScopes = $this->truthyScopes;
2428+
$scope->falseyScopes = $this->falseyScopes;
2429+
2430+
return $scope;
24212431
}
24222432

24232433
/** @api */
@@ -3165,7 +3175,7 @@ public function enterExpressionAssign(Expr $expr): self
31653175
$currentlyAssignedExpressions = $this->currentlyAssignedExpressions;
31663176
$currentlyAssignedExpressions[$exprString] = true;
31673177

3168-
return $this->scopeFactory->create(
3178+
$scope = $this->scopeFactory->create(
31693179
$this->context,
31703180
$this->isDeclareStrictTypes(),
31713181
$this->constantTypes,
@@ -3184,6 +3194,11 @@ public function enterExpressionAssign(Expr $expr): self
31843194
$this->afterExtractCall,
31853195
$this->parentScope,
31863196
);
3197+
$scope->resolvedTypes = $this->resolvedTypes;
3198+
$scope->truthyScopes = $this->truthyScopes;
3199+
$scope->falseyScopes = $this->falseyScopes;
3200+
3201+
return $scope;
31873202
}
31883203

31893204
public function exitExpressionAssign(Expr $expr): self
@@ -3192,7 +3207,7 @@ public function exitExpressionAssign(Expr $expr): self
31923207
$currentlyAssignedExpressions = $this->currentlyAssignedExpressions;
31933208
unset($currentlyAssignedExpressions[$exprString]);
31943209

3195-
return $this->scopeFactory->create(
3210+
$scope = $this->scopeFactory->create(
31963211
$this->context,
31973212
$this->isDeclareStrictTypes(),
31983213
$this->constantTypes,
@@ -3211,6 +3226,11 @@ public function exitExpressionAssign(Expr $expr): self
32113226
$this->afterExtractCall,
32123227
$this->parentScope,
32133228
);
3229+
$scope->resolvedTypes = $this->resolvedTypes;
3230+
$scope->truthyScopes = $this->truthyScopes;
3231+
$scope->falseyScopes = $this->falseyScopes;
3232+
3233+
return $scope;
32143234
}
32153235

32163236
/** @api */
@@ -3226,7 +3246,7 @@ public function setAllowedUndefinedExpression(Expr $expr): self
32263246
$currentlyAllowedUndefinedExpressions = $this->currentlyAllowedUndefinedExpressions;
32273247
$currentlyAllowedUndefinedExpressions[$exprString] = true;
32283248

3229-
return $this->scopeFactory->create(
3249+
$scope = $this->scopeFactory->create(
32303250
$this->context,
32313251
$this->isDeclareStrictTypes(),
32323252
$this->constantTypes,
@@ -3245,6 +3265,11 @@ public function setAllowedUndefinedExpression(Expr $expr): self
32453265
$this->afterExtractCall,
32463266
$this->parentScope,
32473267
);
3268+
$scope->resolvedTypes = $this->resolvedTypes;
3269+
$scope->truthyScopes = $this->truthyScopes;
3270+
$scope->falseyScopes = $this->falseyScopes;
3271+
3272+
return $scope;
32483273
}
32493274

32503275
public function unsetAllowedUndefinedExpression(Expr $expr): self
@@ -3253,7 +3278,7 @@ public function unsetAllowedUndefinedExpression(Expr $expr): self
32533278
$currentlyAllowedUndefinedExpressions = $this->currentlyAllowedUndefinedExpressions;
32543279
unset($currentlyAllowedUndefinedExpressions[$exprString]);
32553280

3256-
return $this->scopeFactory->create(
3281+
$scope = $this->scopeFactory->create(
32573282
$this->context,
32583283
$this->isDeclareStrictTypes(),
32593284
$this->constantTypes,
@@ -3272,6 +3297,11 @@ public function unsetAllowedUndefinedExpression(Expr $expr): self
32723297
$this->afterExtractCall,
32733298
$this->parentScope,
32743299
);
3300+
$scope->resolvedTypes = $this->resolvedTypes;
3301+
$scope->truthyScopes = $this->truthyScopes;
3302+
$scope->falseyScopes = $this->falseyScopes;
3303+
3304+
return $scope;
32753305
}
32763306

32773307
/** @api */

0 commit comments

Comments
 (0)