From 58c8dbf7bc5be2818ca2616c82839e260d34b525 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Thu, 22 Aug 2024 15:34:08 +0200 Subject: [PATCH] Change NoReturnArrayVariableListRule to ignore array spreads (#139) --- src/Rules/NoReturnArrayVariableListRule.php | 4 ++++ .../Fixture/SkipArraySpreads.php | 16 ++++++++++++++++ .../NoReturnArrayVariableListRuleTest.php | 1 + 3 files changed, 21 insertions(+) create mode 100644 tests/Rules/NoReturnArrayVariableListRule/Fixture/SkipArraySpreads.php diff --git a/src/Rules/NoReturnArrayVariableListRule.php b/src/Rules/NoReturnArrayVariableListRule.php index 5a66536a..f5055602 100644 --- a/src/Rules/NoReturnArrayVariableListRule.php +++ b/src/Rules/NoReturnArrayVariableListRule.php @@ -156,6 +156,10 @@ private function resolveExprCount(Array_ $array): int continue; } + if ($item->unpack === true) { + continue; + } + ++$exprCount; } diff --git a/tests/Rules/NoReturnArrayVariableListRule/Fixture/SkipArraySpreads.php b/tests/Rules/NoReturnArrayVariableListRule/Fixture/SkipArraySpreads.php new file mode 100644 index 00000000..d3ba8d92 --- /dev/null +++ b/tests/Rules/NoReturnArrayVariableListRule/Fixture/SkipArraySpreads.php @@ -0,0 +1,16 @@ +