Skip to content

Commit 71dc424

Browse files
committed
simplify DowngradeIteratorCountToArrayRector
1 parent 2365f06 commit 71dc424

File tree

3 files changed

+2
-38
lines changed

3 files changed

+2
-38
lines changed

phpstan.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,3 @@ parameters:
9999
-
100100
identifier: symplify.seeAnnotationToTest
101101
path: rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php
102-
103-
-
104-
identifier: rector.noIntegerRefactorReturn
105-
path: rules/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector.php

rules-tests/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector/Fixture/skip_in_ternary.php.inc

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

rules/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PhpParser\Node\Expr\New_;
1111
use PhpParser\Node\Expr\Ternary;
1212
use PhpParser\Node\Name\FullyQualified;
13-
use PhpParser\NodeVisitor;
1413
use PHPStan\Type\Type;
1514
use PHPStan\Type\TypeCombinator;
1615
use Rector\NodeAnalyzer\ArgsAnalyzer;
@@ -67,26 +66,11 @@ function test(array|Traversable $data) {
6766
}
6867

6968
/**
70-
* @param Ternary|FuncCall $node
71-
* @return null|FuncCall|NodeVisitor::DONT_TRAVERSE_CHILDREN
69+
* @param FuncCall $node
70+
* @return null|FuncCall
7271
*/
7372
public function refactor(Node $node): null|FuncCall|int
7473
{
75-
if ($node instanceof Ternary) {
76-
$hasIsArrayCheck = (bool) $this->betterNodeFinder->findFirst(
77-
$node,
78-
fn (Node $subNode): bool => $subNode instanceof FuncCall && $this->isName($subNode, 'is_array')
79-
);
80-
81-
// get tgype...
82-
83-
if ($hasIsArrayCheck) {
84-
return NodeVisitor::DONT_TRAVERSE_CHILDREN;
85-
}
86-
87-
return null;
88-
}
89-
9074
if (! $this->isNames($node, ['iterator_count', 'iterator_to_array'])) {
9175
return null;
9276
}

0 commit comments

Comments
 (0)