Skip to content

Commit

Permalink
[PostRector] Move instanceof check early before SimpleParameterProvid…
Browse files Browse the repository at this point in the history
…er static call check (#5907)
  • Loading branch information
samsonasik authored May 22, 2024
1 parent 0621d67 commit b2c9e52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/PostRector/Rector/NameImportingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public function __construct(

public function enterNode(Node $node): ?Node
{
if (! $node instanceof Stmt && ! $node instanceof Param && ! $node instanceof FullyQualified) {
return null;
}

if (! SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_NAMES)) {
return null;
}
Expand All @@ -61,10 +65,6 @@ public function enterNode(Node $node): ?Node
return $this->processNodeName($node, $file);
}

if (! $node instanceof Stmt && ! $node instanceof Param) {
return null;
}

$shouldImportDocBlocks = SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES);
if (! $shouldImportDocBlocks) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/PostRector/Rector/UnusedImportRemovingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function __construct(

public function enterNode(Node $node): ?Node
{
if (! SimpleParameterProvider::provideBoolParameter(Option::REMOVE_UNUSED_IMPORTS)) {
if (! $node instanceof Namespace_ && ! $node instanceof FileWithoutNamespace) {
return null;
}

if (! $node instanceof Namespace_ && ! $node instanceof FileWithoutNamespace) {
if (! SimpleParameterProvider::provideBoolParameter(Option::REMOVE_UNUSED_IMPORTS)) {
return null;
}

Expand Down

0 comments on commit b2c9e52

Please sign in to comment.