Skip to content

Commit

Permalink
Removed greedy array_merge() repeated operation: replaced with sing…
Browse files Browse the repository at this point in the history
…le variadic call
  • Loading branch information
Ocramius authored and sebastianbergmann committed Sep 7, 2019
1 parent 878e34e commit 25599e4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Util/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,38 +380,38 @@ public static function getGroups(string $className, ?string $methodName = ''): a
$groups = [];

if (isset($annotations['method']['author'])) {
$groups = $annotations['method']['author'];
$groups[] = $annotations['method']['author'];
} elseif (isset($annotations['class']['author'])) {
$groups = $annotations['class']['author'];
$groups[] = $annotations['class']['author'];
}

if (isset($annotations['class']['group'])) {
$groups = \array_merge($groups, $annotations['class']['group']);
$groups[] = $annotations['class']['group'];
}

if (isset($annotations['method']['group'])) {
$groups = \array_merge($groups, $annotations['method']['group']);
$groups[] = $annotations['method']['group'];
}

if (isset($annotations['class']['ticket'])) {
$groups = \array_merge($groups, $annotations['class']['ticket']);
$groups[] = $annotations['class']['ticket'];
}

if (isset($annotations['method']['ticket'])) {
$groups = \array_merge($groups, $annotations['method']['ticket']);
$groups[] = $annotations['method']['ticket'];
}

foreach (['method', 'class'] as $element) {
foreach (['small', 'medium', 'large'] as $size) {
if (isset($annotations[$element][$size])) {
$groups[] = $size;
$groups[] = [$size];

break 2;
}
}
}

return \array_unique($groups);
return \array_unique(\array_merge([], ...$groups));
}

public static function getSize(string $className, ?string $methodName): int
Expand Down

0 comments on commit 25599e4

Please sign in to comment.