@@ -5392,6 +5392,7 @@ private function processAssignVar(
5392
5392
}
5393
5393
}
5394
5394
5395
+ $ scopeBeforeAssignEval = $ scope ;
5395
5396
$ scope = $ result ->getScope ();
5396
5397
$ truthySpecifiedTypes = $ this ->typeSpecifier ->specifyTypesInCondition ($ scope , $ assignedExpr , TypeSpecifierContext::createTruthy ());
5397
5398
$ falseySpecifiedTypes = $ this ->typeSpecifier ->specifyTypesInCondition ($ scope , $ assignedExpr , TypeSpecifierContext::createFalsey ());
@@ -5404,7 +5405,7 @@ private function processAssignVar(
5404
5405
$ conditionalExpressions = $ this ->processSureTypesForConditionalExpressionsAfterAssign ($ scope , $ var ->name , $ conditionalExpressions , $ falseySpecifiedTypes , $ falseyType );
5405
5406
$ conditionalExpressions = $ this ->processSureNotTypesForConditionalExpressionsAfterAssign ($ scope , $ var ->name , $ conditionalExpressions , $ falseySpecifiedTypes , $ falseyType );
5406
5407
5407
- $ nodeCallback (new VariableAssignNode ($ var , $ assignedExpr ), $ result -> getScope () );
5408
+ $ nodeCallback (new VariableAssignNode ($ var , $ assignedExpr ), $ scopeBeforeAssignEval );
5408
5409
$ scope = $ scope ->assignVariable ($ var ->name , $ type , $ scope ->getNativeType ($ assignedExpr ), TrinaryLogic::createYes ());
5409
5410
foreach ($ conditionalExpressions as $ exprString => $ holders ) {
5410
5411
$ scope = $ scope ->addConditionalExpressions ($ exprString , $ holders );
@@ -5487,6 +5488,7 @@ private function processAssignVar(
5487
5488
$ nativeValueToWrite = $ scope ->getNativeType ($ assignedExpr );
5488
5489
$ originalValueToWrite = $ valueToWrite ;
5489
5490
$ originalNativeValueToWrite = $ nativeValueToWrite ;
5491
+ $ scopeBeforeAssignEval = $ scope ;
5490
5492
5491
5493
// 3. eval assigned expr
5492
5494
$ result = $ processExprCallback ($ scope );
@@ -5542,11 +5544,11 @@ private function processAssignVar(
5542
5544
5543
5545
if ($ varType ->isArray ()->yes () || !(new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ varType )->yes ()) {
5544
5546
if ($ var instanceof Variable && is_string ($ var ->name )) {
5545
- $ nodeCallback (new VariableAssignNode ($ var , $ assignedPropertyExpr ), $ scope );
5547
+ $ nodeCallback (new VariableAssignNode ($ var , $ assignedPropertyExpr ), $ scopeBeforeAssignEval );
5546
5548
$ scope = $ scope ->assignVariable ($ var ->name , $ valueToWrite , $ nativeValueToWrite , TrinaryLogic::createYes ());
5547
5549
} else {
5548
5550
if ($ var instanceof PropertyFetch || $ var instanceof StaticPropertyFetch) {
5549
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedPropertyExpr , $ isAssignOp ), $ scope );
5551
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedPropertyExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5550
5552
if ($ var instanceof PropertyFetch && $ var ->name instanceof Node \Identifier && !$ isAssignOp ) {
5551
5553
$ scope = $ scope ->assignInitializedProperty ($ scope ->getType ($ var ->var ), $ var ->name ->toString ());
5552
5554
}
@@ -5574,9 +5576,9 @@ private function processAssignVar(
5574
5576
}
5575
5577
} else {
5576
5578
if ($ var instanceof Variable) {
5577
- $ nodeCallback (new VariableAssignNode ($ var , $ assignedPropertyExpr ), $ scope );
5579
+ $ nodeCallback (new VariableAssignNode ($ var , $ assignedPropertyExpr ), $ scopeBeforeAssignEval );
5578
5580
} elseif ($ var instanceof PropertyFetch || $ var instanceof StaticPropertyFetch) {
5579
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedPropertyExpr , $ isAssignOp ), $ scope );
5581
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedPropertyExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5580
5582
if ($ var instanceof PropertyFetch && $ var ->name instanceof Node \Identifier && !$ isAssignOp ) {
5581
5583
$ scope = $ scope ->assignInitializedProperty ($ scope ->getType ($ var ->var ), $ var ->name ->toString ());
5582
5584
}
@@ -5611,6 +5613,7 @@ static function (): void {
5611
5613
$ scope = $ propertyNameResult ->getScope ();
5612
5614
}
5613
5615
5616
+ $ scopeBeforeAssignEval = $ scope ;
5614
5617
$ result = $ processExprCallback ($ scope );
5615
5618
$ hasYield = $ hasYield || $ result ->hasYield ();
5616
5619
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
@@ -5625,7 +5628,7 @@ static function (): void {
5625
5628
if ($ propertyName !== null && $ propertyHolderType ->hasProperty ($ propertyName )->yes ()) {
5626
5629
$ propertyReflection = $ propertyHolderType ->getProperty ($ propertyName , $ scope );
5627
5630
$ assignedExprType = $ scope ->getType ($ assignedExpr );
5628
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scope );
5631
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5629
5632
if ($ propertyReflection ->canChangeTypeAfterAssignment ()) {
5630
5633
if ($ propertyReflection ->hasNativeType ()) {
5631
5634
$ propertyNativeType = $ propertyReflection ->getNativeType ();
@@ -5671,7 +5674,7 @@ static function (): void {
5671
5674
} else {
5672
5675
// fallback
5673
5676
$ assignedExprType = $ scope ->getType ($ assignedExpr );
5674
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scope );
5677
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5675
5678
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ scope ->getNativeType ($ assignedExpr ));
5676
5679
// simulate dynamic property assign by __set to get throw points
5677
5680
if (!$ propertyHolderType ->hasMethod ('__set ' )->no ()) {
@@ -5705,6 +5708,7 @@ static function (): void {
5705
5708
$ scope = $ propertyNameResult ->getScope ();
5706
5709
}
5707
5710
5711
+ $ scopeBeforeAssignEval = $ scope ;
5708
5712
$ result = $ processExprCallback ($ scope );
5709
5713
$ hasYield = $ hasYield || $ result ->hasYield ();
5710
5714
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
@@ -5714,7 +5718,7 @@ static function (): void {
5714
5718
if ($ propertyName !== null ) {
5715
5719
$ propertyReflection = $ scope ->getPropertyReflection ($ propertyHolderType , $ propertyName );
5716
5720
$ assignedExprType = $ scope ->getType ($ assignedExpr );
5717
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scope );
5721
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5718
5722
if ($ propertyReflection !== null && $ propertyReflection ->canChangeTypeAfterAssignment ()) {
5719
5723
if ($ propertyReflection ->hasNativeType ()) {
5720
5724
$ propertyNativeType = $ propertyReflection ->getNativeType ();
@@ -5745,7 +5749,7 @@ static function (): void {
5745
5749
} else {
5746
5750
// fallback
5747
5751
$ assignedExprType = $ scope ->getType ($ assignedExpr );
5748
- $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scope );
5752
+ $ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scopeBeforeAssignEval );
5749
5753
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ scope ->getNativeType ($ assignedExpr ));
5750
5754
}
5751
5755
} elseif ($ var instanceof List_) {
0 commit comments