Skip to content

Commit 6d35e2f

Browse files
minor #48793 Leverage arrow function syntax for closure (tigitz)
This PR was merged into the 6.3 branch. Discussion ---------- Leverage arrow function syntax for closure | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #47658 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | <!-- required for new features --> Rationale in the RFC [here](https://wiki.php.net/rfc/arrow_functions_v2#introduction) It's also notable that using arrow function syntax rather than the classic one has been enforced in the past by symfony core member: symfony/symfony#48069 (comment) So this PR would be consistent. Commits ------- f5802d3a2a Leverage arrow function syntax for closure
2 parents 2917736 + e1bcea7 commit 6d35e2f

File tree

2 files changed

+46
-114
lines changed

2 files changed

+46
-114
lines changed

OptionsResolver.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,9 +1018,7 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
10181018
$fmtActualValue = $this->formatValue($value);
10191019
$fmtAllowedTypes = implode('" or "', $this->allowedTypes[$option]);
10201020
$fmtProvidedTypes = implode('|', array_keys($invalidTypes));
1021-
$allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static function ($item) {
1022-
return str_ends_with($item, '[]');
1023-
})) > 0;
1021+
$allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static fn ($item) => str_ends_with($item, '[]'))) > 0;
10241022

10251023
if (\is_array($value) && $allowedContainsArrayType) {
10261024
throw new InvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $this->formatOptions([$option]), $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
@@ -1281,9 +1279,7 @@ private function formatOptions(array $options): string
12811279
$prefix .= sprintf('[%s]', $this->prototypeIndex);
12821280
}
12831281

1284-
$options = array_map(static function (string $option) use ($prefix): string {
1285-
return sprintf('%s[%s]', $prefix, $option);
1286-
}, $options);
1282+
$options = array_map(static fn (string $option): string => sprintf('%s[%s]', $prefix, $option), $options);
12871283
}
12881284

12891285
return implode('", "', $options);

0 commit comments

Comments
 (0)