Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,3 @@ parameters:
-
identifier: symplify.seeAnnotationToTest
path: rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php

-
identifier: rector.noIntegerRefactorReturn
path: rules/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\NodeVisitor;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use Rector\NodeAnalyzer\ArgsAnalyzer;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -30,7 +28,6 @@ final class DowngradeIteratorCountToArrayRector extends AbstractRector
{
public function __construct(
private readonly ArgsAnalyzer $argsAnalyzer,
private readonly BetterNodeFinder $betterNodeFinder
) {
}

Expand Down Expand Up @@ -67,26 +64,10 @@ function test(array|Traversable $data) {
}

/**
* @param Ternary|FuncCall $node
* @return null|FuncCall|NodeVisitor::DONT_TRAVERSE_CHILDREN
* @param FuncCall $node
*/
public function refactor(Node $node): null|FuncCall|int
public function refactor(Node $node): null|FuncCall
{
if ($node instanceof Ternary) {
$hasIsArrayCheck = (bool) $this->betterNodeFinder->findFirst(
$node,
fn (Node $subNode): bool => $subNode instanceof FuncCall && $this->isName($subNode, 'is_array')
);

// get tgype...

if ($hasIsArrayCheck) {
return NodeVisitor::DONT_TRAVERSE_CHILDREN;
}

return null;
}

if (! $this->isNames($node, ['iterator_count', 'iterator_to_array'])) {
return null;
}
Expand Down