Skip to content

Commit 10e6e0e

Browse files
committed
[deprecation] deprecate file, use getFile() instead
1 parent 07fce83 commit 10e6e0e

File tree

20 files changed

+65
-26
lines changed

20 files changed

+65
-26
lines changed

phpstan.neon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,9 @@ parameters:
478478
message: '#Unable to resolve the template type T in call to static method Webmozart\\Assert\\Assert\:\:isInstanceOfAny\(\)#'
479479
path: rules/DeadCode/Rector/FunctionLike/NarrowWideUnionReturnTypeRector.php
480480

481-
- '#Provide more specific return type "Iterator|PhpParser\\Node" over abstract one#'
481+
- '#Provide more specific return type "Iterator|PhpParser\\Node" over abstract one#'
482+
483+
# BC layer
484+
-
485+
message: '#Access to deprecated property \$file of class Rector\\Rector\\AbstractRector#'
486+
path: src/Rector/AbstractRector.php

rules/CodeQuality/Rector/Coalesce/CoalesceToTernaryRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
namespace Rector\CodeQuality\Rector\Coalesce;
66

7-
use PHPStan\Type\UnionType;
8-
use PHPStan\Type\NullType;
97
use PhpParser\Node;
108
use PhpParser\Node\Expr\ArrayDimFetch;
119
use PhpParser\Node\Expr\BinaryOp\Coalesce;
1210
use PhpParser\Node\Expr\Ternary;
1311
use PHPStan\Type\ErrorType;
1412
use PHPStan\Type\MixedType;
13+
use PHPStan\Type\NullType;
14+
use PHPStan\Type\UnionType;
15+
use Rector\PHPStan\ScopeFetcher;
1516
use Rector\Rector\AbstractRector;
1617
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1718
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
18-
use Rector\PHPStan\ScopeFetcher;
1919

2020
/**
2121
* @see \Rector\Tests\CodeQuality\Rector\Coalesce\CoalesceToTernaryRector\CoalesceToTernaryRectorTest

rules/CodeQuality/Rector/Empty_/SimplifyEmptyCheckOnEmptyArrayRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private function isAllowedExpr(Expr $expr, Scope $scope): bool
152152
return false;
153153
}
154154

155-
$type = $this->allAssignNodePropertyTypeInferer->inferProperty($property, $classReflection, $this->file);
155+
$type = $this->allAssignNodePropertyTypeInferer->inferProperty($property, $classReflection, $this->getFile());
156156
if (! $type instanceof Type) {
157157
return false;
158158
}

rules/CodeQuality/Rector/If_/CompleteMissingIfElseBracketRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public function refactor(Node $node): ?Node
6969
return null;
7070
}
7171

72-
$oldTokens = $this->file->getOldTokens();
72+
$oldTokens = $this->getFile()
73+
->getOldTokens();
7374
if ($this->isIfConditionFollowedByOpeningCurlyBracket($node, $oldTokens)) {
7475
return null;
7576
}

rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public function refactor(Node $node): ?NotEqual
6262
$tokenEndPos = $node->getEndTokenPos();
6363

6464
for ($i = $tokenStartPos; $i < $tokenEndPos; ++$i) {
65-
$token = $this->file->getOldTokens()[$i];
65+
$token = $this->getFile()
66+
->getOldTokens()[$i];
6667

6768
if ((string) $token === '<>') {
6869
$token->text = '!=';

rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function getNodeTypes(): array
5252
public function refactor(Node $node): ?Node
5353
{
5454
$hasVariableBeenWrapped = false;
55-
$oldTokens = $this->file->getOldTokens();
55+
$oldTokens = $this->getFile()
56+
->getOldTokens();
5657

5758
foreach ($node->parts as $index => $nodePart) {
5859
if ($nodePart instanceof Variable && $nodePart->getStartTokenPos() >= 0) {

rules/DeadCode/Rector/Concat/RemoveConcatAutocastRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private function removeStringCast(Expr $expr): Expr
7979
}
8080

8181
$targetExpr = $expr->expr;
82-
$tokens = $this->file->getOldTokens();
82+
$tokens = $this->getFile()
83+
->getOldTokens();
8384

8485
if ($expr->expr instanceof BinaryOp) {
8586
$castStartTokenPos = $expr->getStartTokenPos();

rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private function processBinaryMulAndDiv(Mul | Div $binaryOp): ?Expr
214214
if ($binaryOp instanceof Mul && $this->isLiteralOne($binaryOp->left) && $this->nodeTypeResolver->isNumberType(
215215
$binaryOp->right
216216
)) {
217-
if ($this->isMulParenthesized($this->file, $binaryOp)) {
217+
if ($this->isMulParenthesized($this->getFile(), $binaryOp)) {
218218
$binaryOp->right->setAttribute(AttributeKey::WRAPPED_IN_PARENTHESES, true);
219219
}
220220

rules/Php53/Rector/Ternary/TernaryToElvisRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function provideMinPhpVersion(): int
7777

7878
private function isParenthesized(Expr $ifExpr, Expr $elseExpr): bool
7979
{
80-
$tokens = $this->file->getOldTokens();
80+
$tokens = $this->getFile()
81+
->getOldTokens();
8182

8283
$ifExprTokenEnd = $ifExpr->getEndTokenPos();
8384
$elseExprTokenStart = $elseExpr->getStartTokenPos();

rules/Php54/Rector/Array_/LongArrayToShortArrayRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function refactor(Node $node): ?Node
7878

7979
$node->setAttribute(AttributeKey::KIND, Array_::KIND_SHORT);
8080

81-
$tokens = $this->file->getOldTokens();
81+
$tokens = $this->getFile()
82+
->getOldTokens();
8283

8384
$startTokenPos = $node->getStartTokenPos();
8485
$endTokenPos = $node->getEndTokenPos();

0 commit comments

Comments
 (0)