Skip to content

Commit f207744

Browse files
committed
implemented
1 parent 62c599d commit f207744

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ public function refactor(Node $node): ?Node
104104
}
105105

106106
$new = $assign->expr;
107+
$variable = $assign->var;
107108
} else {
108109
if (! $stmt->expr instanceof New_) {
109110
continue;
110111
}
111112

112113
$new = $stmt->expr;
114+
$scope = ScopeFetcher::fetch($stmt);
115+
$variable = new Variable($this->variableNaming->createCountedValueName('reflection', $scope));
113116
}
114117

115118
if (! $this->isNames($new->class, ['ReflectionProperty', 'ReflectionMethod'])) {
@@ -123,11 +126,8 @@ public function refactor(Node $node): ?Node
123126
continue;
124127
}
125128

126-
array_splice($node->stmts, $key + 1, 0, [$this->createSetAccessibleExpression($assign->var)]);
129+
array_splice($node->stmts, $key + 1, 0, [$this->createSetAccessibleExpression($variable)]);
127130
} else {
128-
$scope = ScopeFetcher::fetch($stmt);
129-
$variable = new Variable($this->variableNaming->createCountedValueName('reflection', $scope));
130-
131131
$previousStmts = [
132132
new Expression(new Assign($variable, $new)),
133133
$this->createSetAccessibleExpression($variable),

0 commit comments

Comments
 (0)