mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
cs: Enable risky rule static_lambda
.
This commit is contained in:
@@ -138,7 +138,7 @@ class CRUDRoutesLoader extends Loader
|
||||
|
||||
$methods = array_keys(array_filter(
|
||||
$action['methods'],
|
||||
function ($value, $key) { return $value; },
|
||||
static function ($value, $key) { return $value; },
|
||||
ARRAY_FILTER_USE_BOTH
|
||||
));
|
||||
|
||||
|
@@ -325,7 +325,7 @@ class ChillImportUsersCommand extends Command
|
||||
$question
|
||||
->setMultiselect(true)
|
||||
->setAutocompleterValues(array_keys($permissionGroupsByName))
|
||||
->setNormalizer(function ($value) {
|
||||
->setNormalizer(static function ($value) {
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ class PermissionsGroupController extends AbstractController
|
||||
'edit_form' => $editForm->createView(),
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||
'delete_role_scopes_form' => array_map(function ($form) {
|
||||
'delete_role_scopes_form' => array_map(static function ($form) {
|
||||
return $form->createView();
|
||||
}, $deleteRoleScopesForm),
|
||||
'add_role_scopes_form' => $addRoleScopesForm->createView(),
|
||||
@@ -302,7 +302,7 @@ class PermissionsGroupController extends AbstractController
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||
'delete_role_scopes_form' => array_map(function ($form) {
|
||||
'delete_role_scopes_form' => array_map(static function ($form) {
|
||||
return $form->createView();
|
||||
}, $deleteRoleScopesForm),
|
||||
'add_role_scopes_form' => $addRoleScopesForm->createView(),
|
||||
@@ -358,7 +358,7 @@ class PermissionsGroupController extends AbstractController
|
||||
// sort $roleScopes by name
|
||||
usort(
|
||||
$roleScopes,
|
||||
function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
|
||||
static function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
|
||||
if ($a->getScope() === null) {
|
||||
return 1;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ class PermissionsGroupController extends AbstractController
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||
'delete_role_scopes_form' => array_map(function ($form) {
|
||||
'delete_role_scopes_form' => array_map(static function ($form) {
|
||||
return $form->createView();
|
||||
}, $deleteRoleScopesForm),
|
||||
'add_role_scopes_form' => $addRoleScopesForm->createView(),
|
||||
@@ -570,7 +570,7 @@ class PermissionsGroupController extends AbstractController
|
||||
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
|
||||
$expandedRoles[$roleScope->getRole()] =
|
||||
array_map(
|
||||
function (Role $role) {
|
||||
static function (Role $role) {
|
||||
return $role->getRole();
|
||||
},
|
||||
$this->roleHierarchy
|
||||
|
@@ -237,7 +237,7 @@ class UserController extends CRUDController
|
||||
[
|
||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(),
|
||||
'delete_groupcenter_form' => array_map(
|
||||
function (Form $form) {
|
||||
static function (Form $form) {
|
||||
return $form->createView();
|
||||
},
|
||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true)
|
||||
|
@@ -35,7 +35,7 @@ class MenuCompilerPass implements CompilerPassInterface
|
||||
];
|
||||
}
|
||||
|
||||
usort($services, function ($a, $b) {
|
||||
usort($services, static function ($a, $b) {
|
||||
if ($a['priority'] == $b['priority']) {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ class PermissionsGroup
|
||||
public function isRoleScopePresentOnce(ExecutionContextInterface $context)
|
||||
{
|
||||
$roleScopesId = array_map(
|
||||
function (RoleScope $roleScope) {
|
||||
static function (RoleScope $roleScope) {
|
||||
return $roleScope->getId();
|
||||
},
|
||||
$this->getRoleScopes()->toArray()
|
||||
|
@@ -168,7 +168,7 @@ class CSVFormatter implements FormatterInterface
|
||||
|
||||
// gather data in an array
|
||||
foreach ($keys as $key) {
|
||||
$values = array_map(function ($row) use ($key, $alias) {
|
||||
$values = array_map(static function ($row) use ($key, $alias) {
|
||||
if (!array_key_exists($key, $row)) {
|
||||
throw new LogicException("the key '" . $key . "' is declared by "
|
||||
. "the aggregator with alias '" . $alias . "' but is not "
|
||||
@@ -195,7 +195,7 @@ class CSVFormatter implements FormatterInterface
|
||||
$keys = $this->export->getQueryKeys($this->exportData);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$values = array_map(function ($row) use ($key, $export) {
|
||||
$values = array_map(static function ($row) use ($key, $export) {
|
||||
if (!array_key_exists($key, $row)) {
|
||||
throw new LogicException("the key '" . $key . "' is declared by "
|
||||
. "the export with title '" . $export->getTitle() . "' but is not "
|
||||
|
@@ -196,7 +196,7 @@ class CSVListFormatter implements FormatterInterface
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// get an array with all values for this key if possible
|
||||
$values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
$values = array_map(static function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
// store the label in the labelsCache property
|
||||
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
|
||||
}
|
||||
|
@@ -184,7 +184,7 @@ class CSVPivotedListFormatter implements FormatterInterface
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// get an array with all values for this key if possible
|
||||
$values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
$values = array_map(static function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
// store the label in the labelsCache property
|
||||
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
|
||||
}
|
||||
|
@@ -255,7 +255,7 @@ class SpreadsheetListFormatter implements FormatterInterface
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// get an array with all values for this key if possible
|
||||
$values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
$values = array_map(static function ($v) use ($key) { return $v[$key]; }, $this->result);
|
||||
// store the label in the labelsCache property
|
||||
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPostalCodes,
|
||||
function (?PostalCode $pc = null) use ($value) {
|
||||
static function (?PostalCode $pc = null) use ($value) {
|
||||
return call_user_func($value, $pc);
|
||||
}
|
||||
);
|
||||
|
@@ -33,7 +33,7 @@ final class LocationFormType extends AbstractType
|
||||
$builder
|
||||
->add('locationType', EntityType::class, [
|
||||
'class' => EntityLocationType::class,
|
||||
'choice_attr' => function (EntityLocationType $entity) {
|
||||
'choice_attr' => static function (EntityLocationType $entity) {
|
||||
return [
|
||||
'data-address' => $entity->getAddressRequired(),
|
||||
'data-contact' => $entity->getContactData(),
|
||||
|
@@ -117,7 +117,7 @@ trait AppendScopeChoiceTypeTrait
|
||||
|
||||
$builder->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) {
|
||||
static function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) {
|
||||
$form = $event->getForm();
|
||||
$form->add(
|
||||
$builder
|
||||
|
@@ -23,12 +23,12 @@ class ComposedGroupCenterType extends AbstractType
|
||||
{
|
||||
$builder->add('permissionsgroup', EntityType::class, [
|
||||
'class' => 'Chill\MainBundle\Entity\PermissionsGroup',
|
||||
'choice_label' => function (PermissionsGroup $group) {
|
||||
'choice_label' => static function (PermissionsGroup $group) {
|
||||
return $group->getName();
|
||||
},
|
||||
])->add('center', EntityType::class, [
|
||||
'class' => 'Chill\MainBundle\Entity\Center',
|
||||
'choice_label' => function (Center $center) {
|
||||
'choice_label' => static function (Center $center) {
|
||||
return $center->getName();
|
||||
},
|
||||
]);
|
||||
|
@@ -73,7 +73,7 @@ class ComposedRoleScopeType extends AbstractType
|
||||
->add('role', ChoiceType::class, [
|
||||
'choices' => array_combine(array_values($values), array_keys($values)),
|
||||
'placeholder' => 'Choose amongst roles',
|
||||
'choice_attr' => function ($role) use ($rolesWithoutScopes) {
|
||||
'choice_attr' => static function ($role) use ($rolesWithoutScopes) {
|
||||
if (in_array($role, $rolesWithoutScopes)) {
|
||||
return ['data-has-scope' => '0'];
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class ComposedRoleScopeType extends AbstractType
|
||||
])
|
||||
->add('scope', EntityType::class, [
|
||||
'class' => 'ChillMainBundle:Scope',
|
||||
'choice_label' => function (Scope $scope) use ($translatableStringHelper) {
|
||||
'choice_label' => static function (Scope $scope) use ($translatableStringHelper) {
|
||||
return $translatableStringHelper->localize($scope->getName());
|
||||
},
|
||||
'required' => false,
|
||||
|
@@ -82,7 +82,7 @@ class DateIntervalType extends AbstractType
|
||||
'Months' => 'M',
|
||||
'Years' => 'Y',
|
||||
])
|
||||
->setAllowedValues('unit_choices', function ($values) {
|
||||
->setAllowedValues('unit_choices', static function ($values) {
|
||||
if (false === is_array($values)) {
|
||||
throw new InvalidOptionsException('The value `unit_choice` should be an array');
|
||||
}
|
||||
|
@@ -80,10 +80,10 @@ class PickCenterType extends AbstractType
|
||||
|
||||
$builder->add(self::CENTERS_IDENTIFIERS, EntityType::class, [
|
||||
'class' => 'ChillMainBundle:Center',
|
||||
'query_builder' => function (EntityRepository $er) use ($centers) {
|
||||
'query_builder' => static function (EntityRepository $er) use ($centers) {
|
||||
$qb = $er->createQueryBuilder('c');
|
||||
$ids = array_map(
|
||||
function (Center $el) { return $el->getId(); },
|
||||
static function (Center $el) { return $el->getId(); },
|
||||
$centers
|
||||
);
|
||||
|
||||
@@ -91,7 +91,7 @@ class PickCenterType extends AbstractType
|
||||
},
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => function (Center $c) { return $c->getName(); },
|
||||
'choice_label' => static function (Center $c) { return $c->getName(); },
|
||||
'data' => count($this->groupingCenters) > 0 ? null : $centers,
|
||||
]);
|
||||
|
||||
|
@@ -46,7 +46,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
|
||||
foreach ($helper->getCheckboxes() as $name => $c) {
|
||||
$choices = array_combine(
|
||||
array_map(function ($c, $t) {
|
||||
array_map(static function ($c, $t) {
|
||||
if (null !== $t) {
|
||||
return $t;
|
||||
}
|
||||
|
@@ -80,14 +80,14 @@ class PickCenterType extends AbstractType
|
||||
|
||||
$builder
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function ($data) {
|
||||
static function ($data) {
|
||||
if (null === $data) {
|
||||
return ['center' => null];
|
||||
}
|
||||
|
||||
return ['center' => $data];
|
||||
},
|
||||
function ($data) {
|
||||
static function ($data) {
|
||||
return $data['center'];
|
||||
}
|
||||
));
|
||||
|
@@ -75,7 +75,7 @@ class PostalCodeType extends AbstractType
|
||||
$helper = $this->translatableStringHelper;
|
||||
$resolver
|
||||
->setDefault('class', PostalCode::class)
|
||||
->setDefault('choice_label', function (PostalCode $code) use ($helper) {
|
||||
->setDefault('choice_label', static function (PostalCode $code) use ($helper) {
|
||||
return $code->getCode() . ' ' . $code->getName() . ' [' .
|
||||
$helper->localize($code->getCountry()->getName()) . ']';
|
||||
})
|
||||
|
@@ -141,7 +141,7 @@ class ScopePickerType extends AbstractType
|
||||
->join('pg.groupCenters', 'gc')
|
||||
// add center constraint
|
||||
->where($qb->expr()->in('IDENTITY(gc.center)', ':centers'))
|
||||
->setParameter('centers', array_map(fn (Center $c) => $c->getId(), $centers))
|
||||
->setParameter('centers', array_map(static fn (Center $c) => $c->getId(), $centers))
|
||||
// role constraints
|
||||
->andWhere($qb->expr()->in('rs.role', ':roles'))
|
||||
->setParameter('roles', $roles)
|
||||
|
@@ -72,7 +72,7 @@ class UserPickerType extends AbstractType
|
||||
->setAllowedTypes('having_permissions_group_flag', ['string', 'null'])
|
||||
->setDefault('class', User::class)
|
||||
->setDefault('placeholder', 'Choose an user')
|
||||
->setDefault('choice_label', function (User $u) {
|
||||
->setDefault('choice_label', static function (User $u) {
|
||||
return $u->getUsername();
|
||||
})
|
||||
->setDefault('scope', null)
|
||||
|
@@ -49,7 +49,7 @@ class UserType extends AbstractType
|
||||
'required' => false,
|
||||
'placeholder' => 'Choose a main center',
|
||||
'class' => Center::class,
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('c');
|
||||
$qb->addOrderBy('c.name');
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class SearchUserApiProvider implements SearchApiInterface
|
||||
|
||||
public function prepare(array $metadatas): void
|
||||
{
|
||||
$ids = array_map(fn ($m) => $m['id'], $metadatas);
|
||||
$ids = array_map(static fn ($m) => $m['id'], $metadatas);
|
||||
|
||||
$this->userRepository->findBy(['id' => $ids]);
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ class SearchApi
|
||||
private function findQueries($pattern, array $types, array $parameters): array
|
||||
{
|
||||
return array_map(
|
||||
fn ($p) => $p->provideQuery($pattern, $parameters),
|
||||
static fn ($p) => $p->provideQuery($pattern, $parameters),
|
||||
$this->findProviders($pattern, $types, $parameters),
|
||||
);
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ class SearchProvider
|
||||
public function getByOrder()
|
||||
{
|
||||
//sort the array
|
||||
uasort($this->searchServices, function (SearchInterface $a, SearchInterface $b) {
|
||||
uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) {
|
||||
if ($a->getOrder() == $b->getOrder()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class SearchProvider
|
||||
public function getHasAdvancedFormSearchServices()
|
||||
{
|
||||
//sort the array
|
||||
uasort($this->hasAdvancedFormSearchServices, function (SearchInterface $a, SearchInterface $b) {
|
||||
uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) {
|
||||
if ($a->getOrder() == $b->getOrder()) {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -230,7 +230,7 @@ class ExportManagerTest extends KernelTestCase
|
||||
Argument::Type('array'),
|
||||
Argument::is(['a' => 'b'])
|
||||
)
|
||||
->will(function () use ($em) {
|
||||
->will(static function () use ($em) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
|
||||
return $qb->addSelect('COUNT(user.id) as export')
|
||||
@@ -254,7 +254,7 @@ class ExportManagerTest extends KernelTestCase
|
||||
Argument::is([0, 1]),
|
||||
Argument::Type('array')
|
||||
)
|
||||
->willReturn(function ($value) {
|
||||
->willReturn(static function ($value) {
|
||||
switch ($value) {
|
||||
case 0:
|
||||
case 1:
|
||||
@@ -294,7 +294,7 @@ class ExportManagerTest extends KernelTestCase
|
||||
Argument::is(['cat a', 'cat b']),
|
||||
Argument::is([])
|
||||
)
|
||||
->willReturn(function ($value) {
|
||||
->willReturn(static function ($value) {
|
||||
switch ($value) {
|
||||
case '_header': return 'foo_header';
|
||||
|
||||
|
@@ -50,7 +50,7 @@ class ExtractDateFromPatternTest extends TestCase
|
||||
$this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound());
|
||||
|
||||
$dates = array_map(
|
||||
function (DateTimeImmutable $d) {
|
||||
static function (DateTimeImmutable $d) {
|
||||
return $d->format('Y-m-d');
|
||||
},
|
||||
$result->getFound()
|
||||
|
@@ -206,7 +206,7 @@ class AuthorizationHelperTest extends KernelTestCase
|
||||
$centerA
|
||||
);
|
||||
|
||||
$usernames = array_map(function (User $u) { return $u->getUsername(); }, $users);
|
||||
$usernames = array_map(static function (User $u) { return $u->getUsername(); }, $users);
|
||||
|
||||
$this->assertContains('center a_social', $usernames);
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ class DateRangeCoveringTest extends TestCase
|
||||
$intersections = $cover->getIntersections();
|
||||
|
||||
// sort the intersections to compare them in expected order
|
||||
usort($intersections, function ($a, $b) {
|
||||
usort($intersections, static function ($a, $b) {
|
||||
if ($a[0] === $b[0]) {
|
||||
return $a[1] <=> $b[1];
|
||||
}
|
||||
|
@@ -360,7 +360,7 @@ class CountriesInfo
|
||||
if (null === self::$cacheCountriesCodeByContinent) {
|
||||
$data = self::getArrayCountriesData();
|
||||
|
||||
array_walk($data, function ($item, $key) {
|
||||
array_walk($data, static function ($item, $key) {
|
||||
self::$cacheCountriesCodeByContinent[$item[0]][] = $item[1];
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user