From 7ff049ce5c40522715cbae46cf921837ca68de2e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 09:33:08 +0200 Subject: [PATCH] Use getFile() instead of removed $this->file property rector-src no longer exposes the internal $this->file property on AbstractRector; read the current file via getFile() instead. --- composer.json | 2 +- .../DowngradeTrailingCommasInFunctionCallsRector.php | 6 +++--- .../Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php | 4 ++-- .../Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php | 4 ++-- .../DowngradeDereferenceableOperationRector.php | 2 +- .../ClassMethod/DowngradeTrailingCommasInParamUseRector.php | 4 ++-- .../Rector/Class_/DowngradeAttributeToAnnotationRector.php | 2 +- .../New_/DowngradeArbitraryExpressionsSupportRector.php | 2 +- .../DowngradeNullsafeToTernaryOperatorRector.php | 4 ++-- .../DowngradeNewMethodCallWithoutParenthesesRector.php | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index bcd0f6de..330e782b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^13.2", "rector/jack": "^1.0", - "rector/rector-src": "dev-main", + "rector/rector-src": "dev-tv-enter-node-to-refactor as dev-main", "rector/swiss-knife": "^2.4", "shipmonk/dead-code-detector": "^1.4", "symplify/easy-coding-standard": "^13.2", diff --git a/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php b/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php index 13d91e43..bb5454b9 100644 --- a/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php +++ b/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php @@ -87,7 +87,7 @@ public function refactor(Node $node): ?Node foreach ($args as $arg) { // reprinted, needs to remove from call like itself if ($arg->getEndTokenPos() < 0) { - $hasChanged = $this->trailingCommaRemover->removeFromCallLike($this->file, $node); + $hasChanged = $this->trailingCommaRemover->removeFromCallLike($this->getFile(), $node); if ($hasChanged) { return $node; @@ -100,11 +100,11 @@ public function refactor(Node $node): ?Node $lastArgKey = count($args) - 1; $lastArg = $args[$lastArgKey]; - if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $lastArg)) { + if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $lastArg)) { return null; } - $this->trailingCommaRemover->remove($this->file, $lastArg); + $this->trailingCommaRemover->remove($this->getFile(), $lastArg); return $node; } diff --git a/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php b/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php index ca3430e5..401bec19 100644 --- a/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php +++ b/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php @@ -75,7 +75,7 @@ public function refactor(Node $node): ?Node // skip correctly indented $docIndentation = (string) $node->getAttribute(AttributeKey::DOC_INDENTATION); if ($docIndentation === '' && - $this->followedByNewlineOnlyMaybeWithSemicolonAnalyzer->isFollowed($this->file, $node) + $this->followedByNewlineOnlyMaybeWithSemicolonAnalyzer->isFollowed($this->getFile(), $node) ) { return null; } @@ -83,7 +83,7 @@ public function refactor(Node $node): ?Node $node->setAttribute(AttributeKey::DOC_INDENTATION, '__REMOVED__'); $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); - $tokens = $this->file->getOldTokens(); + $tokens = $this->getFile()->getOldTokens(); if (isset($tokens[$node->getEndTokenPos()], $tokens[$node->getEndTokenPos() + 1])) { $tokens[$node->getEndTokenPos() + 1]->text = "\n" . $tokens[$node->getEndTokenPos() + 1]->text; } diff --git a/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php b/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php index f6fe6cdf..89e5637c 100644 --- a/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php +++ b/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php @@ -64,11 +64,11 @@ public function refactor(Node $node): ?Node $lastArgumentPosition = array_key_last($node->vars); $last = $node->vars[$lastArgumentPosition]; - if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $last)) { + if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $last)) { return null; } - $this->trailingCommaRemover->remove($this->file, $last); + $this->trailingCommaRemover->remove($this->getFile(), $last); return $node; } diff --git a/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php b/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php index 6dd11357..0878fcd5 100644 --- a/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php +++ b/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php @@ -89,7 +89,7 @@ private function hasParentheses(ArrayDimFetch $arrayDimFetch): bool } assert($arrayDimFetch->dim instanceof Expr); // already checked in shouldSkip() - $oldTokens = $this->file->getOldTokens(); + $oldTokens = $this->getFile()->getOldTokens(); $varEndTokenPos = $arrayDimFetch->var->getEndTokenPos(); $dimStartTokenPos = $arrayDimFetch->dim->getStartTokenPos(); diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php index 1f8f75e2..037855bd 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php @@ -123,11 +123,11 @@ private function cleanTrailingComma(Closure|ClassMethod|Function_ $node, array $ } $last = $array[$lastPosition]; - if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $last)) { + if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $last)) { return null; } - $this->trailingCommaRemover->remove($this->file, $last); + $this->trailingCommaRemover->remove($this->getFile(), $last); return $node; } diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php index c5e0da8c..5419164b 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php @@ -113,7 +113,7 @@ public function refactor(Node $node): ?Node $this->isDowngraded = false; $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $oldTokens = $this->file->getOldTokens(); + $oldTokens = $this->getFile()->getOldTokens(); foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $key => $attribute) { diff --git a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php index aa2d3454..a69a2981 100644 --- a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php +++ b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php @@ -102,7 +102,7 @@ private function isAssign(Expr $expr): bool private function isBetweenParentheses(Node $node): bool { - $oldTokens = $this->file->getOldTokens(); + $oldTokens = $this->getFile()->getOldTokens(); $previousTokenPos = $node->getStartTokenPos() - 1; while ($previousTokenPos >= 0) { diff --git a/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php b/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php index 0588851d..3e4428bd 100644 --- a/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php +++ b/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php @@ -60,12 +60,12 @@ public function refactor(Node $node): null|Ternary|Expression { static $currentFile = null; - if ($currentFile !== $this->file->getFilePath()) { + if ($currentFile !== $this->getFile()->getFilePath()) { // the counter need start from 0 when visit new file to avoid random increment // across files // due to run on parallel $this->counter = 0; - $currentFile = $this->file->getFilePath(); + $currentFile = $this->getFile()->getFilePath(); } if ($node instanceof Expression) { diff --git a/rules/DowngradePhp84/Rector/MethodCall/DowngradeNewMethodCallWithoutParenthesesRector.php b/rules/DowngradePhp84/Rector/MethodCall/DowngradeNewMethodCallWithoutParenthesesRector.php index 97d3cccd..e7a58e42 100644 --- a/rules/DowngradePhp84/Rector/MethodCall/DowngradeNewMethodCallWithoutParenthesesRector.php +++ b/rules/DowngradePhp84/Rector/MethodCall/DowngradeNewMethodCallWithoutParenthesesRector.php @@ -53,7 +53,7 @@ public function refactor(Node $node): ?Node return null; } - $oldTokens = $this->file->getOldTokens(); + $oldTokens = $this->getFile()->getOldTokens(); $startTokenPos = $node->getStartTokenPos(); $endTokenPos = $node->getEndTokenPos();