Replaced regular callbacks by arrow functions when possible

This commit is contained in:
Alejandro Celaya
2019-12-29 23:16:55 +01:00
parent a830420d75
commit bfeb915cd2
19 changed files with 42 additions and 75 deletions

View File

@@ -75,9 +75,10 @@ class SimplifiedConfigParser
// This mainly allows deprecating keys and defining new ones that will replace the older and always take
// preference, while the old one keeps working for backwards compatibility if the new one is not provided.
$simplifiedConfigOrder = array_flip(array_keys(self::SIMPLIFIED_CONFIG_MAPPING));
uksort($configForExistingKeys, function (string $a, string $b) use ($simplifiedConfigOrder): int {
return $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b];
});
uksort(
$configForExistingKeys,
fn (string $a, string $b): int => $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b]
);
return $configForExistingKeys;
}

View File

@@ -188,9 +188,7 @@ class ShortUrl extends AbstractEntity
$shortUrlTags = invoke($this->getTags(), '__toString');
$hasAllTags = count($shortUrlTags) === count($tags) && array_reduce(
$tags,
function (bool $hasAllTags, string $tag) use ($shortUrlTags) {
return $hasAllTags && contains($shortUrlTags, $tag);
},
fn (bool $hasAllTags, string $tag) => $hasAllTags && contains($shortUrlTags, $tag),
true
);

View File

@@ -69,12 +69,10 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
private function invalidElementsToString(): string
{
return reduce_left($this->getInvalidElements(), function ($messageSet, string $name, $_, string $acc) {
return $acc . sprintf(
"\n '%s' => %s",
$name,
is_array($messageSet) ? print_r($messageSet, true) : $messageSet
);
}, '');
return reduce_left($this->getInvalidElements(), fn ($messages, string $name, $_, string $acc) => $acc . sprintf(
"\n '%s' => %s",
$name,
is_array($messages) ? print_r($messages, true) : $messages
), '');
}
}