Skip to content

Commit 0249dd8

Browse files
committed
update to php-parser 5 nodes
1 parent 27ee014 commit 0249dd8

File tree

30 files changed

+68
-71
lines changed

30 files changed

+68
-71
lines changed

rules/DowngradePhp72/NodeManipulator/JsonConstCleaner.php

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

55
namespace Rector\DowngradePhp72\NodeManipulator;
66

7+
use PhpParser\Node\Scalar\Int_;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr;
910
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
1011
use PhpParser\Node\Expr\ConstFetch;
11-
use PhpParser\Node\Scalar\LNumber;
1212
use Rector\Enum\JsonConstant;
1313
use Rector\NodeNameResolver\NodeNameResolver;
1414
use Rector\NodeTypeResolver\Node\AttributeKey;
@@ -35,19 +35,19 @@ public function clean(ConstFetch|BitwiseOr $node, array $constants): Expr|null
3535
/**
3636
* @param array<JsonConstant::*> $constants
3737
*/
38-
private function cleanByConstFetch(ConstFetch $constFetch, array $constants): ?LNumber
38+
private function cleanByConstFetch(ConstFetch $constFetch, array $constants): ?Int_
3939
{
4040
if (! $this->nodeNameResolver->isNames($constFetch, $constants)) {
4141
return null;
4242
}
4343

44-
return new LNumber(0);
44+
return new Int_(0);
4545
}
4646

4747
/**
4848
* @param array<JsonConstant::*> $constants
4949
*/
50-
private function cleanByBitwiseOr(BitwiseOr $bitwiseOr, array $constants): null|Expr|LNumber
50+
private function cleanByBitwiseOr(BitwiseOr $bitwiseOr, array $constants): null|Expr|Int_
5151
{
5252
$isLeftTransformed = $this->isTransformed($bitwiseOr->left, $constants);
5353
$isRightTransformed = $this->isTransformed($bitwiseOr->right, $constants);
@@ -64,7 +64,7 @@ private function cleanByBitwiseOr(BitwiseOr $bitwiseOr, array $constants): null|
6464
return $bitwiseOr->right;
6565
}
6666

67-
return new LNumber(0);
67+
return new Int_(0);
6868
}
6969

7070
/**

rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\DowngradePhp72\PhpDoc;
66

7+
use PhpParser\Node;
78
use PhpParser\Node\Expr;
89
use PhpParser\Node\Param;
910
use PhpParser\Node\Stmt\ClassMethod;
@@ -29,7 +30,7 @@ public function __construct(
2930

3031
public function decorate(ClassMethod $classMethod, Param $param): void
3132
{
32-
if ($param->type === null) {
33+
if (!$param->type instanceof Node) {
3334
return;
3435
}
3536

rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\DowngradePhp72\Rector\FuncCall;
66

7+
use PhpParser\Node\Scalar\Int_;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr\Assign;
910
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
@@ -14,7 +15,6 @@
1415
use PhpParser\Node\Expr\FuncCall;
1516
use PhpParser\Node\Expr\Variable;
1617
use PhpParser\Node\Param;
17-
use PhpParser\Node\Scalar\LNumber;
1818
use PhpParser\Node\Scalar\String_;
1919
use PhpParser\Node\Stmt;
2020
use PhpParser\Node\Stmt\ClassConst;
@@ -150,7 +150,7 @@ private function refactorClassConst(ClassConst $classConst): ?ClassConst
150150
continue;
151151
}
152152

153-
$classConst->consts[$key]->value = new LNumber(512);
153+
$classConst->consts[$key]->value = new Int_(512);
154154
return $classConst;
155155
}
156156

rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,6 @@ private function hasConstFetchInBitwiseOr(BitwiseOr $bitwiseOr, string $constNam
266266
$found = false;
267267

268268
foreach ([$bitwiseOr->left, $bitwiseOr->right] as $subNode) {
269-
// Only `Node` instances can hold the constant.
270-
if (! ($subNode instanceof Node)) {
271-
continue;
272-
}
273-
274269
$found = match (true) {
275270
$subNode instanceof BitwiseOr => (
276271
$this->hasConstFetchInBitwiseOr($subNode, $constName)

rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Rector\DowngradePhp73\Rector\FuncCall;
66

7+
use PhpParser\Node\ArrayItem;
78
use PhpParser\BuilderHelpers;
89
use PhpParser\Node;
910
use PhpParser\Node\Arg;
1011
use PhpParser\Node\Expr\Array_;
11-
use PhpParser\Node\Expr\ArrayItem;
1212
use PhpParser\Node\Expr\FuncCall;
1313
use PhpParser\Node\Scalar\String_;
1414
use Rector\Exception\ShouldNotHappenException;

rules/DowngradePhp73/Rector/List_/DowngradeListReferenceAssignmentRector.php

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

55
namespace Rector\DowngradePhp73\Rector\List_;
66

7+
use PhpParser\Node\ArrayItem;
8+
use PhpParser\Node\Scalar\Int_;
79
use PhpParser\BuilderHelpers;
810
use PhpParser\Node;
911
use PhpParser\Node\Expr\Array_;
1012
use PhpParser\Node\Expr\ArrayDimFetch;
11-
use PhpParser\Node\Expr\ArrayItem;
1213
use PhpParser\Node\Expr\Assign;
1314
use PhpParser\Node\Expr\AssignRef;
1415
use PhpParser\Node\Expr\List_;
1516
use PhpParser\Node\Expr\Variable;
16-
use PhpParser\Node\Scalar\LNumber;
1717
use PhpParser\Node\Scalar\String_;
1818
use PhpParser\Node\Stmt\Expression;
1919
use Rector\Rector\AbstractRector;
@@ -157,7 +157,7 @@ private function shouldSkipAssign(Assign $assign, List_ | Array_ $arrayOrList):
157157
/**
158158
* Count the number of params by reference placed at the end
159159
* These params are not needed anymore, so they can be removed
160-
* @param (ArrayItem|null)[] $listItems
160+
* @param (ArrayItem | null)[] $listItems
161161
*/
162162
private function countRightSideMostParamsByRefOrEmpty(array $listItems): int
163163
{
@@ -192,7 +192,7 @@ private function countRightSideMostParamsByRefOrEmpty(array $listItems): int
192192
}
193193

194194
/**
195-
* @param (ArrayItem|null)[] $listItems
195+
* @param (ArrayItem | null)[] $listItems
196196
* @param (int|string)[] $nestedArrayIndexes
197197
* @return Node\Stmt[]
198198
*/
@@ -250,7 +250,7 @@ private function createAssignRefArrayFromListReferences(
250250
* - list(&$a, $b)
251251
* - list($a, $b, list(&$c, $d))
252252
*
253-
* @param (ArrayItem|null)[] $items
253+
* @param (ArrayItem | null)[] $items
254254
*/
255255
private function hasAnyItemByRef(array $items): bool
256256
{
@@ -262,7 +262,7 @@ private function hasAnyItemByRef(array $items): bool
262262
* - list(&$a, &$b)
263263
* - list(&$a, &$b, list(&$c, &$d))
264264
*
265-
* @param (ArrayItem|null)[] $items
265+
* @param (ArrayItem | null)[] $items
266266
*/
267267
private function hasAllItemsByRef(array $items): bool
268268
{
@@ -278,7 +278,7 @@ private function getArrayItemKey(ArrayItem $arrayItem, int | string $position):
278278
return $arrayItem->key->value;
279279
}
280280

281-
if ($arrayItem->key instanceof LNumber) {
281+
if ($arrayItem->key instanceof Int_) {
282282
return $arrayItem->key->value;
283283
}
284284

@@ -309,7 +309,7 @@ private function createAssignRefWithArrayDimFetch(
309309
}
310310

311311
/**
312-
* @param array<ArrayItem|null> $arrayItems
312+
* @param array<(ArrayItem | null)> $arrayItems
313313
* @return ArrayItem[]
314314
*/
315315
private function getItemsByRef(array $arrayItems, int $condition): array

rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php

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

55
namespace Rector\DowngradePhp73\Rector\String_;
66

7+
use PhpParser\Node\Scalar\InterpolatedString;
78
use PhpParser\Node;
8-
use PhpParser\Node\Scalar\Encapsed;
99
use PhpParser\Node\Scalar\String_;
1010
use Rector\DowngradePhp73\Tokenizer\FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer;
1111
use Rector\NodeTypeResolver\Node\AttributeKey;
@@ -59,11 +59,11 @@ public function getRuleDefinition(): RuleDefinition
5959
*/
6060
public function getNodeTypes(): array
6161
{
62-
return [String_::class, Encapsed::class];
62+
return [String_::class, InterpolatedString::class];
6363
}
6464

6565
/**
66-
* @param Encapsed|String_ $node
66+
* @param InterpolatedString|String_ $node
6767
*/
6868
public function refactor(Node $node): ?Node
6969
{

rules/DowngradePhp73/Tokenizer/FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public function isFollowed(File $file, Node $node): bool
2121

2222
return ! isset($oldTokens[$nextTokenPosition]) ||
2323
isset($oldTokens[$nextTokenPosition][1]) &&
24-
\str_starts_with($oldTokens[$nextTokenPosition][1], "\n");
24+
\str_starts_with((string) $oldTokens[$nextTokenPosition][1], "\n");
2525
}
2626
}

rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Rector\DowngradePhp74\Rector\Array_;
66

7+
use PhpParser\Node\ArrayItem;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr\Array_;
9-
use PhpParser\Node\Expr\ArrayItem;
1010
use PhpParser\Node\Expr\ClassConstFetch;
1111
use PhpParser\Node\Identifier;
1212
use PhpParser\Node\Name;

rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Rector\DowngradePhp74\Rector\ArrowFunction;
66

7+
use PhpParser\Node\ClosureUse;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr;
910
use PhpParser\Node\Expr\ArrowFunction;
1011
use PhpParser\Node\Expr\Assign;
1112
use PhpParser\Node\Expr\Closure;
12-
use PhpParser\Node\Expr\ClosureUse;
1313
use PhpParser\Node\Expr\Variable;
1414
use PhpParser\Node\Stmt\Return_;
1515
use PhpParser\Node\Stmt\Throw_;

0 commit comments

Comments
 (0)