From 597c6b12b041a6a9b2c328b1a6c111fafb4f2d1b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 3 Aug 2026 14:36:47 +0200 Subject: [PATCH 1/2] [CodingStyle] Deprecate CountArrayToEmptyArrayComparisonRector --- ...tArrayToEmptyArrayComparisonRectorTest.php | 28 --- .../Fixture/fixture_from_local_var.php.inc | 35 ---- .../Fixture/fixture_from_method_call.php.inc | 43 ----- .../Fixture/fixture_from_parameter.php.inc | 33 ---- .../fixture_mark_as_truthy_check.php.inc | 41 ---- ...ture_mark_as_truthy_negation_check.php.inc | 29 --- ..._negation_check_inside_conditional.php.inc | 33 ---- ...ruthy_negation_check_inside_or_and.php.inc | 35 ---- .../Fixture/fixture_not_identical.php.inc | 45 ----- .../Fixture/skip_countable_instance.php.inc | 16 -- ...skip_mark_as_truthy_check_in_while.php.inc | 18 -- .../Fixture/skip_not_array.php.inc | 15 -- .../Fixture/skip_not_count.php.inc | 13 -- .../Fixture/skip_phpdoc.php.inc | 14 -- .../config/configured_rule.php | 9 - ...CountArrayToEmptyArrayComparisonRector.php | 177 +----------------- src/Config/Level/CodingStyleLevel.php | 2 - .../CountArrayLongToShortTest.php | 28 --- .../count_to_empty_array_compare.php.inc | 33 ---- .../config/configured_rule.php | 10 - ...ountArrayOnTruthyEmptyArrayCompareTest.php | 28 --- .../Issues/Issue6561/Fixture/fixture.php.inc | 33 ---- .../on_call_method_return_array.php.inc | 49 ----- .../Issue6561/config/configured_rule.php | 10 - 24 files changed, 9 insertions(+), 768 deletions(-) delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/CountArrayToEmptyArrayComparisonRectorTest.php delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_local_var.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_method_call.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_parameter.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_check.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_conditional.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_or_and.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_not_identical.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_countable_instance.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_mark_as_truthy_check_in_while.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_array.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_count.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_phpdoc.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/config/configured_rule.php delete mode 100644 tests/Issues/CountArrayLongToShort/CountArrayLongToShortTest.php delete mode 100644 tests/Issues/CountArrayLongToShort/Fixture/count_to_empty_array_compare.php.inc delete mode 100644 tests/Issues/CountArrayLongToShort/config/configured_rule.php delete mode 100644 tests/Issues/Issue6561/CountArrayOnTruthyEmptyArrayCompareTest.php delete mode 100644 tests/Issues/Issue6561/Fixture/fixture.php.inc delete mode 100644 tests/Issues/Issue6561/Fixture/on_call_method_return_array.php.inc delete mode 100644 tests/Issues/Issue6561/config/configured_rule.php diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/CountArrayToEmptyArrayComparisonRectorTest.php b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/CountArrayToEmptyArrayComparisonRectorTest.php deleted file mode 100644 index 892e52ed46d..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/CountArrayToEmptyArrayComparisonRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_local_var.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_local_var.php.inc deleted file mode 100644 index 11360e94ffe..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_local_var.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - 0; - 0 < count($localArray); - } -} - -?> ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_method_call.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_method_call.php.inc deleted file mode 100644 index 94b3264e21d..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_method_call.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -getData()) === 0; - 0 === count($this->getData()); - count($this->getData()) > 0; - 0 < count($this->getData()); - } - - public function getData(): array - { - return []; - } -} - -?> ------ -getData() === []; - [] === $this->getData(); - $this->getData() !== []; - [] !== $this->getData(); - } - - public function getData(): array - { - return []; - } -} - -?> diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_parameter.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_parameter.php.inc deleted file mode 100644 index e62513a3e88..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_from_parameter.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - 0; - 0 < count($array); - } -} - -?> ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_check.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_check.php.inc deleted file mode 100644 index 64176736ff1..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_check.php.inc +++ /dev/null @@ -1,41 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check.php.inc deleted file mode 100644 index 332b29cdd3d..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_conditional.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_conditional.php.inc deleted file mode 100644 index 4bba9a77d8b..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_conditional.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_or_and.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_or_and.php.inc deleted file mode 100644 index c7730a981b1..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_mark_as_truthy_negation_check_inside_or_and.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_not_identical.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_not_identical.php.inc deleted file mode 100644 index 15a75d2c3b0..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/fixture_not_identical.php.inc +++ /dev/null @@ -1,45 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_countable_instance.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_countable_instance.php.inc deleted file mode 100644 index 2418a5d7337..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_countable_instance.php.inc +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_array.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_array.php.inc deleted file mode 100644 index 64d19899384..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_array.php.inc +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_count.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_count.php.inc deleted file mode 100644 index 45d7e5af89e..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_not_count.php.inc +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_phpdoc.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_phpdoc.php.inc deleted file mode 100644 index c8020094384..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/Fixture/skip_phpdoc.php.inc +++ /dev/null @@ -1,14 +0,0 @@ - 0) { - -} - - -?> diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/config/configured_rule.php b/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/config/configured_rule.php deleted file mode 100644 index 8d03684bbdc..00000000000 --- a/rules-tests/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([CountArrayToEmptyArrayComparisonRector::class]); diff --git a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php index ae5b820707a..0ee4bf26f13 100644 --- a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php @@ -5,25 +5,17 @@ namespace Rector\CodingStyle\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Expr; -use PhpParser\Node\Expr\Array_; -use PhpParser\Node\Expr\BinaryOp\Greater; use PhpParser\Node\Expr\BinaryOp\Identical; -use PhpParser\Node\Expr\BinaryOp\NotIdentical; -use PhpParser\Node\Expr\BinaryOp\Smaller; -use PhpParser\Node\Expr\BooleanNot; -use PhpParser\Node\Expr\FuncCall; -use PhpParser\Node\Scalar\Int_; -use PhpParser\Node\Stmt\ElseIf_; -use PhpParser\Node\Stmt\If_; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @see \Rector\Tests\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector\CountArrayToEmptyArrayComparisonRectorTest + * @deprecated This rule is deprecated, as it is a coding standard preference with no real value. Use a coding standard tool instead. */ -final class CountArrayToEmptyArrayComparisonRector extends AbstractRector +final class CountArrayToEmptyArrayComparisonRector extends AbstractRector implements DeprecatedInterface { public function getRuleDefinition(): RuleDefinition { @@ -52,165 +44,14 @@ public function getRuleDefinition(): RuleDefinition */ public function getNodeTypes(): array { - return [ - Identical::class, - NotIdentical::class, - BooleanNot::class, - Greater::class, - Smaller::class, - If_::class, - ElseIf_::class, - ]; + return [Identical::class]; } - /** - * @param Identical|NotIdentical|BooleanNot|Greater|Smaller|If_|ElseIf_ $node - */ public function refactor(Node $node): ?Node { - if ($node instanceof BooleanNot) { - return $this->refactorBooleanNot($node); - } - - if ($node instanceof Identical || $node instanceof NotIdentical) { - if ($node->left instanceof FuncCall) { - $expr = $this->matchCountFuncCallArgExpr($node->left); - } elseif ($node->right instanceof FuncCall) { - $expr = $this->matchCountFuncCallArgExpr($node->right); - } else { - return null; - } - - if (! $expr instanceof Expr) { - return null; - } - - // not pass array type, skip - if (! $this->isArray($expr)) { - return null; - } - - return $this->refactorIdenticalOrNotIdentical($node, $expr); - } - - if ($node instanceof Smaller || $node instanceof Greater) { - return $this->refactorGreaterOrSmaller($node); - } - - return $this->refactorIfElseIf($node); - } - - private function refactorBooleanNot(BooleanNot $booleanNot): ?Identical - { - $expr = $this->matchCountFuncCallArgExpr($booleanNot->expr); - if (! $expr instanceof Expr) { - return null; - } - - // not pass array type, skip - if (! $this->isArray($expr)) { - return null; - } - - return new Identical($expr, new Array_([])); - } - - private function isArray(Expr $expr): bool - { - return $this->nodeTypeResolver->getNativeType($expr) - ->isArray() - ->yes(); - } - - private function refactorIdenticalOrNotIdentical( - Identical|NotIdentical $binaryOp, - Expr $expr - ): Identical|NotIdentical|null { - if ($this->isZeroLNumber($binaryOp->right)) { - $binaryOp->left = $expr; - $binaryOp->right = new Array_([]); - - return $binaryOp; - } - - if ($this->isZeroLNumber($binaryOp->left)) { - $binaryOp->left = new Array_([]); - $binaryOp->right = $expr; - - return $binaryOp; - } - - return null; - } - - private function refactorGreaterOrSmaller(Greater|Smaller $binaryOp): NotIdentical|null - { - if ($binaryOp instanceof Greater) { - $leftExpr = $this->matchCountFuncCallArgExpr($binaryOp->left); - if (! $leftExpr instanceof Expr) { - return null; - } - - if (! $this->isZeroLNumber($binaryOp->right)) { - return null; - } - - return new NotIdentical($leftExpr, new Array_([])); - } - - $rightExpr = $this->matchCountFuncCallArgExpr($binaryOp->right); - if (! $rightExpr instanceof Expr) { - return null; - } - - if (! $this->isZeroLNumber($binaryOp->left)) { - return null; - } - - return new NotIdentical(new Array_([]), $rightExpr); - } - - private function refactorIfElseIf(If_|ElseIf_ $ifElseIf): If_|ElseIf_|null - { - $expr = $this->matchCountFuncCallArgExpr($ifElseIf->cond); - if (! $expr instanceof Expr) { - return null; - } - - $ifElseIf->cond = new NotIdentical($expr, new Array_([])); - - return $ifElseIf; - } - - private function matchCountFuncCallArgExpr(Expr $expr): ?Expr - { - if (! $expr instanceof FuncCall) { - return null; - } - - if (! $this->isName($expr, 'count')) { - return null; - } - - if ($expr->isFirstClassCallable()) { - return null; - } - - $firstArg = $expr->getArgs()[0]; - - if (! $this->isArray($firstArg->value)) { - return null; - } - - return $firstArg->value; - } - - private function isZeroLNumber(Expr $expr): bool - { - if (! $expr instanceof Int_) { - return false; - } - - return $expr->value === 0; + throw new ShouldNotHappenException(sprintf( + '"%s" rule is deprecated, as it is a coding standard preference with no real value', + self::class + )); } } diff --git a/src/Config/Level/CodingStyleLevel.php b/src/Config/Level/CodingStyleLevel.php index 5ae4c4db1d0..4a2fe71ec84 100644 --- a/src/Config/Level/CodingStyleLevel.php +++ b/src/Config/Level/CodingStyleLevel.php @@ -13,7 +13,6 @@ use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector; use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector; -use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector; use Rector\CodingStyle\Rector\FuncCall\StrictInArrayRector; use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; @@ -58,7 +57,6 @@ final class CodingStyleLevel MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, - CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, diff --git a/tests/Issues/CountArrayLongToShort/CountArrayLongToShortTest.php b/tests/Issues/CountArrayLongToShort/CountArrayLongToShortTest.php deleted file mode 100644 index f7377e4a126..00000000000 --- a/tests/Issues/CountArrayLongToShort/CountArrayLongToShortTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/CountArrayLongToShort/Fixture/count_to_empty_array_compare.php.inc b/tests/Issues/CountArrayLongToShort/Fixture/count_to_empty_array_compare.php.inc deleted file mode 100644 index 7008101cb70..00000000000 --- a/tests/Issues/CountArrayLongToShort/Fixture/count_to_empty_array_compare.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/tests/Issues/CountArrayLongToShort/config/configured_rule.php b/tests/Issues/CountArrayLongToShort/config/configured_rule.php deleted file mode 100644 index 7bbf55deaa2..00000000000 --- a/tests/Issues/CountArrayLongToShort/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -withRules([CountArrayToEmptyArrayComparisonRector::class, LongArrayToShortArrayRector::class]); diff --git a/tests/Issues/Issue6561/CountArrayOnTruthyEmptyArrayCompareTest.php b/tests/Issues/Issue6561/CountArrayOnTruthyEmptyArrayCompareTest.php deleted file mode 100644 index 75dcfc9cfca..00000000000 --- a/tests/Issues/Issue6561/CountArrayOnTruthyEmptyArrayCompareTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/Issue6561/Fixture/fixture.php.inc b/tests/Issues/Issue6561/Fixture/fixture.php.inc deleted file mode 100644 index d422a973104..00000000000 --- a/tests/Issues/Issue6561/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/tests/Issues/Issue6561/Fixture/on_call_method_return_array.php.inc b/tests/Issues/Issue6561/Fixture/on_call_method_return_array.php.inc deleted file mode 100644 index 5fdbbbf649f..00000000000 --- a/tests/Issues/Issue6561/Fixture/on_call_method_return_array.php.inc +++ /dev/null @@ -1,49 +0,0 @@ -get(); - - if (count($array)) { - } - } - - /** - * @return string[] - */ - private function get(): array - { - return ['a', 'b']; - } -} - -?> ------ -get(); - - if ($array !== []) { - } - } - - /** - * @return string[] - */ - private function get(): array - { - return ['a', 'b']; - } -} - -?> diff --git a/tests/Issues/Issue6561/config/configured_rule.php b/tests/Issues/Issue6561/config/configured_rule.php deleted file mode 100644 index 02c16dd5993..00000000000 --- a/tests/Issues/Issue6561/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -withRules([ExplicitBoolCompareRector::class, CountArrayToEmptyArrayComparisonRector::class]); From f13e4f73bda01202d1b9a0361432b2685fad859c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 3 Aug 2026 12:38:43 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php index 0ee4bf26f13..1eefb017442 100644 --- a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php @@ -47,6 +47,9 @@ public function getNodeTypes(): array return [Identical::class]; } + /** + * @param Identical $node + */ public function refactor(Node $node): ?Node { throw new ShouldNotHappenException(sprintf(