Skip to content

Commit 545452a

Browse files
authored
[perf] Skip current file lookup when rule makes no change on RectorRunner::run() (#8891)
1 parent e0f59a8 commit 545452a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/Rector/RectorRunner.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function __construct(
4646
*/
4747
public function run(RectorInterface $rector, Node $node): int|Node|null|array
4848
{
49-
$file = $this->getFile();
50-
$filePath = $file->getFilePath();
51-
5249
// ensure origNode pulled before refactor to avoid changed during refactor, ref https://3v4l.org/YMEGN
5350
$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE) ?? $node;
5451

@@ -64,6 +61,9 @@ public function run(RectorInterface $rector, Node $node): int|Node|null|array
6461
throw new ShouldNotHappenException($errorMessage);
6562
}
6663

64+
$file = $this->getFile();
65+
$filePath = $file->getFilePath();
66+
6767
if (is_int($refactoredNodeOrState)) {
6868
// only remove node is supported
6969
if ($refactoredNodeOrState !== NodeVisitor::REMOVE_NODE) {

0 commit comments

Comments
 (0)