diff --git a/rules-tests/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector/Fixture/skip_in_ternary.php.inc b/rules-tests/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector/Fixture/skip_in_ternary.php.inc new file mode 100644 index 00000000..e36ee42b --- /dev/null +++ b/rules-tests/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector/Fixture/skip_in_ternary.php.inc @@ -0,0 +1,16 @@ +betterNodeFinder->findFirst( + $node, + fn (Node $subNode): bool => $subNode instanceof FuncCall && $this->isName($subNode, 'is_array') + ); + + if ($hasIsArrayCheck) { + return NodeTraverser::DONT_TRAVERSE_CHILDREN; + } + + return null; + } + if (! $this->isNames($node, ['iterator_count', 'iterator_to_array'])) { return null; } @@ -107,6 +124,7 @@ private function shouldSkip(Type $type): bool return false; } + $type = TypeCombinator::removeNull($type); return $type->isObject() ->yes(); }