Skip to content

Commit

Permalink
Apply whitespace changes from phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Jan 10, 2025
1 parent bccdffc commit 3421e00
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
26 changes: 15 additions & 11 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1686,20 +1686,24 @@ private function parseSniffCodes($input, $argument)
}
}//end foreach

$sniffs = array_reduce($sniffs, static function ($carry, $item) {
$lower = strtolower($item);

foreach ($carry as $found) {
if ($lower === strtolower($found)) {
// This sniff is already in our list.
return $carry;
$sniffs = array_reduce(
$sniffs,
static function ($carry, $item) {
$lower = strtolower($item);

foreach ($carry as $found) {
if ($lower === strtolower($found)) {
// This sniff is already in our list.
return $carry;
}
}
}

$carry[] = $item;
$carry[] = $item;

return $carry;
}, []);
return $carry;
},
[]
);

if ($errors !== []) {
$error = 'ERROR: The --'.$argument.' option only supports sniff codes.'.PHP_EOL;
Expand Down
20 changes: 10 additions & 10 deletions tests/Core/Config/SniffsExcludeArgsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,25 @@ public static function dataInvalidSniffs()
foreach ($arguments as $argument) {
// Empty values are errors.
$data[$argument.'; empty string'] = [
'argument' => $argument,
'value' => '',
'errors' => [
'argument' => $argument,
'value' => '',
'errors' => [
'No codes specified / empty argument',
],
'suggestion' => null,
];
$data[$argument.'; one comma alone'] = [
'argument' => $argument,
'value' => ',',
'errors' => [
'argument' => $argument,
'value' => ',',
'errors' => [
'No codes specified / empty argument',
],
'suggestion' => null,
];
$data[$argument.'; two commas alone'] = [
'argument' => $argument,
'value' => ',,',
'errors' => [
'argument' => $argument,
'value' => ',,',
'errors' => [
'No codes specified / empty argument',
],
'suggestion' => null,
Expand Down Expand Up @@ -229,7 +229,7 @@ public static function dataValidSniffs()
];

// Rogue commas are quietly ignored.
$data[$argument.'; trailing comma'] = [
$data[$argument.'; trailing comma'] = [
'argument' => $argument,
'value' => 'Standard.Category.Sniff,',
'result' => ['Standard.Category.Sniff'],
Expand Down

0 comments on commit 3421e00

Please sign in to comment.