Skip to content

Commit

Permalink
[Performance] Avoid ReflectionProvider check function exists on NameI…
Browse files Browse the repository at this point in the history
…mportingPostRector (#5083)

* [Performance] Remove ReflectionProvider check function exists on NameImportingPostRector

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 26, 2023
1 parent 50e589c commit 50eb9ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/BetterPhpDocParser/PhpDoc/ArrayItemNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __toString(): string
$value .= $singleValue;
}
} elseif ($this->value instanceof DoctrineAnnotationTagValueNode) {
$value .= (string) $this->value->identifierTypeNode . $this->value;
$value .= $this->value->identifierTypeNode . $this->value;
} else {
$value .= $this->value;
}
Expand Down
8 changes: 1 addition & 7 deletions packages/PostRector/Rector/NameImportingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use PhpParser\Node\Stmt\InlineHTML;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Use_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
Expand All @@ -37,7 +36,6 @@ public function __construct(
private readonly DocBlockNameImporter $docBlockNameImporter,
private readonly ClassNameImportSkipper $classNameImportSkipper,
private readonly PhpDocInfoFactory $phpDocInfoFactory,
private readonly ReflectionProvider $reflectionProvider,
private readonly CurrentFileProvider $currentFileProvider,
private readonly UseImportsResolver $useImportsResolver,
private readonly AliasNameResolver $aliasNameResolver,
Expand Down Expand Up @@ -208,10 +206,6 @@ private function shouldImportName(Name $name, array $currentUses): bool
return true;
}

if ($this->classNameImportSkipper->isAlreadyImported($name, $currentUses)) {
return true;
}

return $this->reflectionProvider->hasFunction(new Name($name->getLast()), null);
return $this->classNameImportSkipper->isAlreadyImported($name, $currentUses);
}
}

0 comments on commit 50eb9ef

Please sign in to comment.