Skip to content

Commit 51dfcd2

Browse files
authored
Apply "static_lambda" CS rule under src/ dir (api-platform#3725)
1 parent 2d8e89a commit 51dfcd2

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

src/Bridge/Doctrine/MongoDbOdm/Filter/OrderFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class OrderFilter extends AbstractFilter implements OrderFilterInterface
4343
public function __construct(ManagerRegistry $managerRegistry, string $orderParameterName = 'order', LoggerInterface $logger = null, array $properties = null, NameConverterInterface $nameConverter = null)
4444
{
4545
if (null !== $properties) {
46-
$properties = array_map(function ($propertyOptions) {
46+
$properties = array_map(static function ($propertyOptions) {
4747
// shorthand for default direction
4848
if (\is_string($propertyOptions)) {
4949
$propertyOptions = [

src/Bridge/Doctrine/MongoDbOdm/SubresourceDataProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ private function buildAggregation(array $identifiers, array $context, Builder $p
157157
$aggregation = $this->buildAggregation($identifiers, $context, $aggregation, --$remainingIdentifiers, $topAggregationBuilder);
158158

159159
$results = $aggregation->execute()->toArray();
160-
$in = array_reduce($results, function ($in, $result) use ($previousAssociationProperty) {
161-
return $in + array_map(function ($result) {
160+
$in = array_reduce($results, static function ($in, $result) use ($previousAssociationProperty) {
161+
return $in + array_map(static function ($result) {
162162
return $result['_id'];
163163
}, $result[$previousAssociationProperty] ?? []);
164164
}, []);

src/Bridge/Doctrine/Orm/Filter/OrderFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OrderFilter extends AbstractContextAwareFilter implements OrderFilterInter
4444
public function __construct(ManagerRegistry $managerRegistry, ?RequestStack $requestStack = null, string $orderParameterName = 'order', LoggerInterface $logger = null, array $properties = null, NameConverterInterface $nameConverter = null)
4545
{
4646
if (null !== $properties) {
47-
$properties = array_map(function ($propertyOptions) {
47+
$properties = array_map(static function ($propertyOptions) {
4848
// shorthand for default direction
4949
if (\is_string($propertyOptions)) {
5050
$propertyOptions = [

src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private function addSwaggerSection(ArrayNodeDefinition $rootNode): void
284284
})
285285
->end()
286286
->validate()
287-
->ifTrue(function ($v) use ($defaultVersions) {
287+
->ifTrue(static function ($v) use ($defaultVersions) {
288288
return $v !== array_intersect($v, $defaultVersions);
289289
})
290290
->thenInvalid(sprintf('Only the versions %s are supported. Got %s.', implode(' and ', $defaultVersions), '%s'))
@@ -337,7 +337,7 @@ private function addHttpCacheSection(ArrayNodeDefinition $rootNode): void
337337
->variableNode('request_options')
338338
->defaultValue([])
339339
->validate()
340-
->ifTrue(function ($v) { return false === \is_array($v); })
340+
->ifTrue(static function ($v) { return false === \is_array($v); })
341341
->thenInvalid('The request_options parameter must be an array.')
342342
->end()
343343
->info('To pass options to the client charged with the request.')
@@ -435,7 +435,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
435435
->useAttributeAsKey('exception_class')
436436
->beforeNormalization()
437437
->ifArray()
438-
->then(function (array $exceptionToStatus) {
438+
->then(static function (array $exceptionToStatus) {
439439
foreach ($exceptionToStatus as &$httpStatusCode) {
440440
if (\is_int($httpStatusCode)) {
441441
continue;
@@ -454,7 +454,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
454454
->prototype('integer')->end()
455455
->validate()
456456
->ifArray()
457-
->then(function (array $exceptionToStatus) {
457+
->then(static function (array $exceptionToStatus) {
458458
foreach ($exceptionToStatus as $httpStatusCode) {
459459
if ($httpStatusCode < 100 || $httpStatusCode >= 600) {
460460
throw new InvalidConfigurationException(sprintf('The HTTP status code "%s" is not valid.', $httpStatusCode));
@@ -479,7 +479,7 @@ private function addFormatSection(ArrayNodeDefinition $rootNode, string $key, ar
479479
->useAttributeAsKey('format')
480480
->beforeNormalization()
481481
->ifArray()
482-
->then(function ($v) {
482+
->then(static function ($v) {
483483
foreach ($v as $format => $value) {
484484
if (isset($value['mime_types'])) {
485485
continue;

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function getFilterArgs(array $args, ?string $resourceClass, ?ResourceMet
327327
if (\array_key_exists($key, $parsed) && \is_array($parsed[$key])) {
328328
$parsed = [$key => ''];
329329
}
330-
array_walk_recursive($parsed, function (&$value) use ($graphqlFilterType) {
330+
array_walk_recursive($parsed, static function (&$value) use ($graphqlFilterType) {
331331
$value = $graphqlFilterType;
332332
});
333333
$args = $this->mergeFilterArgs($args, $parsed, $resourceMetadata, $key);

src/HttpCache/VarnishPurger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function purge(array $iris)
4444
}
4545

4646
// Create the regex to purge all tags in just one request
47-
$parts = array_map(function ($iri) {
47+
$parts = array_map(static function ($iri) {
4848
return sprintf('(^|\,)%s($|\,)', preg_quote($iri));
4949
}, $iris);
5050

src/Security/Core/Authorization/ExpressionLanguageProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ final class ExpressionLanguageProvider implements ExpressionFunctionProviderInte
2626
public function getFunctions(): array
2727
{
2828
return [
29-
new ExpressionFunction('is_granted', function ($attributes, $object = 'null') {
29+
new ExpressionFunction('is_granted', static function ($attributes, $object = 'null') {
3030
return sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object);
31-
}, function (array $variables, $attributes, $object = null) {
31+
}, static function (array $variables, $attributes, $object = null) {
3232
return $variables['auth_checker']->isGranted($attributes, $object);
3333
}),
3434
];

src/Security/ExpressionLanguage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ protected function registerFunctions()
4040
{
4141
parent::registerFunctions();
4242

43-
$this->register('is_granted', function ($attributes, $object = 'null') {
43+
$this->register('is_granted', static function ($attributes, $object = 'null') {
4444
return sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object);
45-
}, function (array $variables, $attributes, $object = null) {
45+
}, static function (array $variables, $attributes, $object = null) {
4646
return $variables['auth_checker']->isGranted($attributes, $object);
4747
});
4848
}

src/Security/ResourceAccessChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function getEffectiveRoles(TokenInterface $token): array
8888
return $this->roleHierarchy->getReachableRoleNames($token->getRoleNames());
8989
}
9090

91-
return array_map(function (Role $role): string { // @phpstan-ignore-line
91+
return array_map(static function (Role $role): string { // @phpstan-ignore-line
9292
return $role->getRole(); // @phpstan-ignore-line
9393
}, $this->roleHierarchy->getReachableRoles($token->getRoles())); // @phpstan-ignore-line
9494
}

src/Util/RequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function parseRequestParams(string $source): array
5555

5656
$source = preg_replace_callback(
5757
'/(^|(?<=&))[^=[&]+/',
58-
function ($key) {
58+
static function ($key) {
5959
return bin2hex(urldecode($key[0]));
6060
},
6161
$source

0 commit comments

Comments
 (0)