Skip to content

Commit

Permalink
refactor: remove useless array flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinludwig committed Jan 20, 2025
1 parent 818c85c commit 9e82366
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Checkers/SourceCodeChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,24 @@ private function getMethodParameters(ReflectionMethod $method): array
*/
private function getConstantNames(ReflectionClass $reflection): array
{
return array_merge(...array_values((array_map(
function (ReflectionClassConstant $constant) use ($reflection): array {
foreach ($reflection->getTraits() as $trait) {
if ($trait->hasConstant($constant->getName())) {
return [];
return array_map(
fn (ReflectionClassConstant $constant): string => $constant->name,
array_filter(
$reflection->getReflectionConstants(),
function (ReflectionClassConstant $constant) use ($reflection): bool {
if ($constant->class !== $reflection->name) {
return false;
}
foreach ($reflection->getTraits() as $trait) {
if ($trait->hasConstant($constant->getName())) {
return false;
}
}
}
if ($constant->class !== $reflection->name) {
return [];
}

return [$constant->name];
},
$reflection->getReflectionConstants()
))));
return true;
}
)
);
}

/**
Expand Down

0 comments on commit 9e82366

Please sign in to comment.