Skip to content

Commit 0c89e06

Browse files
committed
Add "static_lambda" CS rule
1 parent cb3f641 commit 0c89e06

File tree

11 files changed

+18
-17
lines changed

11 files changed

+18
-17
lines changed

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ return PhpCsFixer\Config::create()
100100
'phpdoc_trim_consecutive_blank_line_separation' => true,
101101
'phpdoc_var_annotation_correct_order' => true,
102102
'return_assignment' => true,
103+
'static_lambda' => true,
103104
'strict_param' => true,
104105
'visibility_required' => [
105106
'elements' => [

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
@@ -164,8 +164,8 @@ private function buildAggregation(array $identifiers, array $context, array $exe
164164
$aggregation = $this->buildAggregation($identifiers, $context, $executeOptions, $aggregation, --$remainingIdentifiers, $topAggregationBuilder);
165165

166166
$results = $aggregation->execute($executeOptions)->toArray();
167-
$in = array_reduce($results, function ($in, $result) use ($previousAssociationProperty) {
168-
return $in + array_map(function ($result) {
167+
$in = array_reduce($results, static function ($in, $result) use ($previousAssociationProperty) {
168+
return $in + array_map(static function ($result) {
169169
return $result['_id'];
170170
}, $result[$previousAssociationProperty] ?? []);
171171
}, []);

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
@@ -313,7 +313,7 @@ private function addSwaggerSection(ArrayNodeDefinition $rootNode): void
313313
})
314314
->end()
315315
->validate()
316-
->ifTrue(function ($v) use ($defaultVersions) {
316+
->ifTrue(static function ($v) use ($defaultVersions) {
317317
return $v !== array_intersect($v, $defaultVersions);
318318
})
319319
->thenInvalid(sprintf('Only the versions %s are supported. Got %s.', implode(' and ', $defaultVersions), '%s'))
@@ -383,7 +383,7 @@ private function addHttpCacheSection(ArrayNodeDefinition $rootNode): void
383383
->variableNode('request_options')
384384
->defaultValue([])
385385
->validate()
386-
->ifTrue(function ($v) { return false === \is_array($v); })
386+
->ifTrue(static function ($v) { return false === \is_array($v); })
387387
->thenInvalid('The request_options parameter must be an array.')
388388
->end()
389389
->info('To pass options to the client charged with the request.')
@@ -481,7 +481,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
481481
->useAttributeAsKey('exception_class')
482482
->beforeNormalization()
483483
->ifArray()
484-
->then(function (array $exceptionToStatus) {
484+
->then(static function (array $exceptionToStatus) {
485485
foreach ($exceptionToStatus as &$httpStatusCode) {
486486
if (\is_int($httpStatusCode)) {
487487
continue;
@@ -500,7 +500,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
500500
->prototype('integer')->end()
501501
->validate()
502502
->ifArray()
503-
->then(function (array $exceptionToStatus) {
503+
->then(static function (array $exceptionToStatus) {
504504
foreach ($exceptionToStatus as $httpStatusCode) {
505505
if ($httpStatusCode < 100 || $httpStatusCode >= 600) {
506506
throw new InvalidConfigurationException(sprintf('The HTTP status code "%s" is not valid.', $httpStatusCode));
@@ -525,7 +525,7 @@ private function addFormatSection(ArrayNodeDefinition $rootNode, string $key, ar
525525
->useAttributeAsKey('format')
526526
->beforeNormalization()
527527
->ifArray()
528-
->then(function ($v) {
528+
->then(static function ($v) {
529529
foreach ($v as $format => $value) {
530530
if (isset($value['mime_types'])) {
531531
continue;

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private function getFilterArgs(array $args, ?string $resourceClass, ?ResourceMet
395395
if (\array_key_exists($key, $parsed) && \is_array($parsed[$key])) {
396396
$parsed = [$key => ''];
397397
}
398-
array_walk_recursive($parsed, function (&$value) use ($graphqlFilterType) {
398+
array_walk_recursive($parsed, static function (&$value) use ($graphqlFilterType) {
399399
$value = $graphqlFilterType;
400400
});
401401
$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
@@ -82,7 +82,7 @@ public function purge(array $iris)
8282
private function purgeRequest(array $iris)
8383
{
8484
// Create the regex to purge all tags in just one request
85-
$parts = array_map(function ($iri) {
85+
$parts = array_map(static function ($iri) {
8686
return sprintf('(^|\,)%s($|\,)', preg_quote($iri));
8787
}, $iris);
8888

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 {
91+
return array_map(static function (Role $role): string {
9292
return $role->getRole();
9393
}, $this->roleHierarchy->getReachableRoles($token->getRoles()));
9494
}

0 commit comments

Comments
 (0)