|
36 | 36 | use PhpParser\Node\Expr\MethodCall; |
37 | 37 | use PhpParser\Node\Expr\New_; |
38 | 38 | use PhpParser\Node\Expr\NullsafeMethodCall; |
39 | | -use PhpParser\Node\Expr\PostDec; |
40 | | -use PhpParser\Node\Expr\PostInc; |
41 | | -use PhpParser\Node\Expr\PreDec; |
42 | | -use PhpParser\Node\Expr\PreInc; |
43 | 39 | use PhpParser\Node\Expr\Print_; |
44 | 40 | use PhpParser\Node\Expr\PropertyFetch; |
45 | 41 | use PhpParser\Node\Expr\StaticCall; |
|
52 | 48 | use PhpParser\Node\Expr\Yield_; |
53 | 49 | use PhpParser\Node\Expr\YieldFrom; |
54 | 50 | use PhpParser\Node\Identifier; |
55 | | -use PhpParser\Node\IntersectionType; |
56 | 51 | use PhpParser\Node\Name; |
57 | 52 | use PhpParser\Node\NullableType; |
58 | 53 | use PhpParser\Node\Stmt; |
|
75 | 70 | use PhpParser\Node\Stmt\TryCatch; |
76 | 71 | use PhpParser\Node\Stmt\Unset_; |
77 | 72 | use PhpParser\Node\Stmt\While_; |
78 | | -use PhpParser\Node\UnionType; |
79 | 73 | use PhpParser\NodeTraverser; |
80 | 74 | use PHPStan\Analyser\MutatingScope; |
81 | 75 | use PHPStan\Analyser\NodeCallbackScope; |
|
102 | 96 | use Rector\NodeTypeResolver\Node\AttributeKey; |
103 | 97 | use Rector\PhpParser\Node\FileNode; |
104 | 98 | use Rector\Util\Reflection\PrivatesAccessor; |
105 | | -use Webmozart\Assert\Assert; |
106 | 99 |
|
107 | 100 | /** |
108 | 101 | * @inspired by https://github.com/silverstripe/silverstripe-upgrader/blob/532182b23e854d02e0b27e68ebc394f436de0682/src/UpgradeRule/PHP/Visitor/PHPStanScopeVisitor.php |
@@ -226,14 +219,6 @@ private function fillScope(array $stmts, string $filePath, MutatingScope $scope) |
226 | 219 | return; |
227 | 220 | } |
228 | 221 |
|
229 | | - if ($node instanceof PostInc || |
230 | | - $node instanceof PostDec || |
231 | | - $node instanceof PreInc || |
232 | | - $node instanceof PreDec) { |
233 | | - $node->var->setAttribute(AttributeKey::SCOPE, $mutatingScope); |
234 | | - return; |
235 | | - } |
236 | | - |
237 | 222 | if ($node instanceof ArrayDimFetch) { |
238 | 223 | $node->var->setAttribute(AttributeKey::SCOPE, $mutatingScope); |
239 | 224 | if ($node->dim instanceof Expr) { |
@@ -318,14 +303,6 @@ private function fillScope(array $stmts, string $filePath, MutatingScope $scope) |
318 | 303 | return; |
319 | 304 | } |
320 | 305 |
|
321 | | - if ($node instanceof UnionType || $node instanceof IntersectionType) { |
322 | | - foreach ($node->types as $type) { |
323 | | - $type->setAttribute(AttributeKey::SCOPE, $mutatingScope); |
324 | | - } |
325 | | - |
326 | | - return; |
327 | | - } |
328 | | - |
329 | 306 | if ($node instanceof StaticPropertyFetch || $node instanceof ClassConstFetch) { |
330 | 307 | $node->class->setAttribute(AttributeKey::SCOPE, $mutatingScope); |
331 | 308 | $node->name->setAttribute(AttributeKey::SCOPE, $mutatingScope); |
@@ -479,8 +456,6 @@ private function nodeScopeResolverProcessNodes( |
479 | 456 | MutatingScope $mutatingScope, |
480 | 457 | callable $nodeCallback |
481 | 458 | ): void { |
482 | | - Assert::allIsInstanceOf($stmts, Stmt::class); |
483 | | - |
484 | 459 | try { |
485 | 460 | $this->nodeScopeResolver->processNodes($stmts, $mutatingScope, $nodeCallback); |
486 | 461 | } catch (ParserErrorsException|ParserException|ShouldNotHappenException|UndefinedVariableException) { |
|
0 commit comments