Skip to content

Commit 869385b

Browse files
committed
remove beforeTraverse() from nullsafe method call; counter is not relevant as output is already ternary nesting
1 parent 5a4fd67 commit 869385b

File tree

21 files changed

+9
-84
lines changed

21 files changed

+9
-84
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"phpstan/phpstan": "^2.1.32",
1212
"phpstan/phpstan-webmozart-assert": "^2.0",
1313
"phpunit/phpunit": "^11.5",
14-
"rector/rector-src": "dev-main",
14+
"rector/rector-src": "dev-tv-rector-avoid-before-traverser",
1515
"rector/type-perfect": "^2.1",
1616
"symplify/easy-coding-standard": "^12.3",
1717
"symplify/phpstan-extensions": "^12.0",

phpstan.neon

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ parameters:
99

1010
# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
1111
typeAliases:
12-
StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\CustomNode\FileWithoutNamespace
12+
StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode
1313

1414
# requires exact closure types
1515
checkMissingCallableSignature: true
@@ -92,13 +92,3 @@ parameters:
9292
-
9393
identifier: symplify.forbiddenFuncCall
9494
path: rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php
95-
96-
# false positive
97-
-
98-
identifier: symplify.seeAnnotationToTest
99-
path: rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php
100-
101-
# handle next
102-
-
103-
identifier: method.parentMethodFinalByPhpDoc
104-
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/get_nullable.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class GetNullable
2727
{
2828
public function run($value)
2929
{
30-
return ($nullsafeVariable1 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable1->value : null;
30+
return ($nullsafeVariable6 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable6->value : null;
3131
}
3232

3333
protected function extractArrayItemByKey($value): ?ArrayItem

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/get_nullable_in_trait.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ trait GetNullableInTrait
2929
{
3030
public function run($value)
3131
{
32-
return ($nullsafeVariable1 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable1->value : null;
32+
return ($nullsafeVariable7 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable7->value : null;
3333
}
3434

3535
protected function extractArrayItemByKey($value): ?ArrayItem

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/multiple_call.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class MultipleCall
2121
{
2222
public function run($object)
2323
{
24-
$result = ($nullsafeVariable1 = ($nullsafeVariable2 = $object->multiple($args1)) ? $nullsafeVariable2->call($args2) : null) ? $nullsafeVariable1->otherCall($args3) : null;
25-
$result = ($nullsafeVariable3 = ($nullsafeVariable4 = ($nullsafeVariable5 = $object->multiple($args1)) ? $nullsafeVariable5->call($args2) : null) ? $nullsafeVariable4->otherCall($args3) : null) ? $nullsafeVariable3->anotherCall($args4) : null;
24+
$result = ($nullsafeVariable8 = ($nullsafeVariable9 = $object->multiple($args1)) ? $nullsafeVariable9->call($args2) : null) ? $nullsafeVariable8->otherCall($args3) : null;
25+
$result = ($nullsafeVariable10 = ($nullsafeVariable11 = ($nullsafeVariable12 = $object->multiple($args1)) ? $nullsafeVariable12->call($args2) : null) ? $nullsafeVariable11->otherCall($args3) : null) ? $nullsafeVariable10->anotherCall($args4) : null;
2626
}
2727
}
2828

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/short_circuit.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ShortCircuit
2020
{
2121
public function run(bool $param)
2222
{
23-
return ($nullsafeVariable1 = $this->clock) ? $nullsafeVariable1->now()->format('U.u') : null;
23+
return ($nullsafeVariable13 = $this->clock) ? $nullsafeVariable13->now()->format('U.u') : null;
2424
}
2525
}
2626

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/short_circuit3.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ShortCircuit3
2020
{
2121
public function run(bool $param)
2222
{
23-
return ($nullsafeVariable1 = $this->clock) ? $nullsafeVariable1->now->format : null;
23+
return ($nullsafeVariable14 = $this->clock) ? $nullsafeVariable14->now->format : null;
2424
}
2525
}
2626

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/short_circuit4.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.

rules-tests/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector/Fixture/short_circuit5.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.

rules-tests/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRectorTest/DowngradePipeOperatorRectorTest.php renamed to rules-tests/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector/DowngradePipeOperatorRectorTest.php

File renamed without changes.

0 commit comments

Comments
 (0)