Skip to content

Commit

Permalink
Change NoReturnArrayVariableListRule to ignore array spreads (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-granados authored Aug 22, 2024
1 parent 434d05d commit 58c8dbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Rules/NoReturnArrayVariableListRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ private function resolveExprCount(Array_ $array): int
continue;
}

if ($item->unpack === true) {
continue;
}

++$exprCount;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Symplify\PHPStanRules\Tests\Rules\NoReturnArrayVariableListRule\Fixture;

final class SkipArraySpreads
{
public function run($value)
{
$a = [1, 2, 3];
$b = [4, 5, 6];
return [...$a, ...$b];
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function provideData(): Iterator
yield [__DIR__ . '/Fixture/SkipNews.php', []];
yield [__DIR__ . '/Fixture/ValueObject/SkipValueObject.php', []];
yield [__DIR__ . '/Fixture/SkipParentMethod.php', []];
yield [__DIR__ . '/Fixture/SkipArraySpreads.php', []];
}

/**
Expand Down

0 comments on commit 58c8dbf

Please sign in to comment.