Skip to content

Commit 8253433

Browse files
authored
Use getFile() instead of removed $this->file property (#403)
1 parent 378215a commit 8253433

10 files changed

Lines changed: 16 additions & 16 deletions

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"phpstan/phpstan-webmozart-assert": "^2.0",
1414
"phpunit/phpunit": "^13.2",
1515
"rector/jack": "^1.0",
16-
"rector/rector-src": "dev-main",
16+
"rector/rector-src": "dev-tv-enter-node-to-refactor as dev-main",
1717
"rector/swiss-knife": "^2.4",
1818
"shipmonk/dead-code-detector": "^1.4",
1919
"symplify/easy-coding-standard": "^13.2",

‎rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function refactor(Node $node): ?Node
8787
foreach ($args as $arg) {
8888
// reprinted, needs to remove from call like itself
8989
if ($arg->getEndTokenPos() < 0) {
90-
$hasChanged = $this->trailingCommaRemover->removeFromCallLike($this->file, $node);
90+
$hasChanged = $this->trailingCommaRemover->removeFromCallLike($this->getFile(), $node);
9191

9292
if ($hasChanged) {
9393
return $node;
@@ -100,11 +100,11 @@ public function refactor(Node $node): ?Node
100100
$lastArgKey = count($args) - 1;
101101

102102
$lastArg = $args[$lastArgKey];
103-
if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $lastArg)) {
103+
if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $lastArg)) {
104104
return null;
105105
}
106106

107-
$this->trailingCommaRemover->remove($this->file, $lastArg);
107+
$this->trailingCommaRemover->remove($this->getFile(), $lastArg);
108108

109109
return $node;
110110
}

‎rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ public function refactor(Node $node): ?Node
7575
// skip correctly indented
7676
$docIndentation = (string) $node->getAttribute(AttributeKey::DOC_INDENTATION);
7777
if ($docIndentation === '' &&
78-
$this->followedByNewlineOnlyMaybeWithSemicolonAnalyzer->isFollowed($this->file, $node)
78+
$this->followedByNewlineOnlyMaybeWithSemicolonAnalyzer->isFollowed($this->getFile(), $node)
7979
) {
8080
return null;
8181
}
8282

8383
$node->setAttribute(AttributeKey::DOC_INDENTATION, '__REMOVED__');
8484
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
8585

86-
$tokens = $this->file->getOldTokens();
86+
$tokens = $this->getFile()->getOldTokens();
8787
if (isset($tokens[$node->getEndTokenPos()], $tokens[$node->getEndTokenPos() + 1])) {
8888
$tokens[$node->getEndTokenPos() + 1]->text = "\n" . $tokens[$node->getEndTokenPos() + 1]->text;
8989
}

‎rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function refactor(Node $node): ?Node
6464
$lastArgumentPosition = array_key_last($node->vars);
6565

6666
$last = $node->vars[$lastArgumentPosition];
67-
if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
67+
if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $last)) {
6868
return null;
6969
}
7070

71-
$this->trailingCommaRemover->remove($this->file, $last);
71+
$this->trailingCommaRemover->remove($this->getFile(), $last);
7272

7373
return $node;
7474
}

‎rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function hasParentheses(ArrayDimFetch $arrayDimFetch): bool
8989
}
9090

9191
assert($arrayDimFetch->dim instanceof Expr); // already checked in shouldSkip()
92-
$oldTokens = $this->file->getOldTokens();
92+
$oldTokens = $this->getFile()->getOldTokens();
9393
$varEndTokenPos = $arrayDimFetch->var->getEndTokenPos();
9494
$dimStartTokenPos = $arrayDimFetch->dim->getStartTokenPos();
9595

‎rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ private function cleanTrailingComma(Closure|ClassMethod|Function_ $node, array $
123123
}
124124

125125
$last = $array[$lastPosition];
126-
if (! $this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
126+
if (! $this->followedByCommaAnalyzer->isFollowed($this->getFile(), $last)) {
127127
return null;
128128
}
129129

130-
$this->trailingCommaRemover->remove($this->file, $last);
130+
$this->trailingCommaRemover->remove($this->getFile(), $last);
131131

132132
return $node;
133133
}

‎rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function refactor(Node $node): ?Node
113113
$this->isDowngraded = false;
114114

115115
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
116-
$oldTokens = $this->file->getOldTokens();
116+
$oldTokens = $this->getFile()->getOldTokens();
117117

118118
foreach ($node->attrGroups as $attrGroup) {
119119
foreach ($attrGroup->attrs as $key => $attribute) {

‎rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function isAssign(Expr $expr): bool
102102

103103
private function isBetweenParentheses(Node $node): bool
104104
{
105-
$oldTokens = $this->file->getOldTokens();
105+
$oldTokens = $this->getFile()->getOldTokens();
106106
$previousTokenPos = $node->getStartTokenPos() - 1;
107107

108108
while ($previousTokenPos >= 0) {

‎rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function refactor(Node $node): null|Ternary|Expression
6060
{
6161
static $currentFile = null;
6262

63-
if ($currentFile !== $this->file->getFilePath()) {
63+
if ($currentFile !== $this->getFile()->getFilePath()) {
6464
// the counter need start from 0 when visit new file to avoid random increment
6565
// across files
6666
// due to run on parallel
6767
$this->counter = 0;
68-
$currentFile = $this->file->getFilePath();
68+
$currentFile = $this->getFile()->getFilePath();
6969
}
7070

7171
if ($node instanceof Expression) {

‎rules/DowngradePhp84/Rector/MethodCall/DowngradeNewMethodCallWithoutParenthesesRector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function refactor(Node $node): ?Node
5353
return null;
5454
}
5555

56-
$oldTokens = $this->file->getOldTokens();
56+
$oldTokens = $this->getFile()->getOldTokens();
5757
$startTokenPos = $node->getStartTokenPos();
5858
$endTokenPos = $node->getEndTokenPos();
5959

0 commit comments

Comments
 (0)