mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
cs: Enable risky rule static_lambda
.
This commit is contained in:
parent
a9188355c5
commit
91d12c4a96
@ -63,7 +63,7 @@ $riskyRules = [
|
||||
'php_unit_mock' => false,
|
||||
'php_unit_namespaced' => false,
|
||||
'random_api_migration' => false,
|
||||
'static_lambda' => false,
|
||||
// 'static_lambda' => false,
|
||||
'php_unit_construct' => false,
|
||||
// 'psr_autoloading' => false,
|
||||
'php_unit_dedicate_assert' => false,
|
||||
|
@ -89,7 +89,7 @@ class CountPerson implements ExportInterface
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
// we gather all center the user choose.
|
||||
$centers = array_map(function ($el) { return $el['center']; }, $acl);
|
||||
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@ -56,7 +56,7 @@ class Configuration implements ConfigurationInterface
|
||||
->info('The number of seconds of this duration. Must be an integer.')
|
||||
->cannotBeEmpty()
|
||||
->validate()
|
||||
->ifTrue(function ($data) {
|
||||
->ifTrue(static function ($data) {
|
||||
return !is_int($data);
|
||||
})->thenInvalid('The value %s is not a valid integer')
|
||||
->end()
|
||||
|
@ -75,7 +75,7 @@ class ListActivity implements ListInterface
|
||||
'choices' => array_combine($this->fields, $this->fields),
|
||||
'label' => 'Fields to include in export',
|
||||
'constraints' => [new Callback([
|
||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||
if (count($selected) === 0) {
|
||||
$context->buildViolation('You must select at least one element')
|
||||
->atPath('fields')
|
||||
@ -189,7 +189,7 @@ class ListActivity implements ListInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(function ($el) { return $el['center']; }, $acl);
|
||||
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
|
@ -125,7 +125,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('socialIssues', HiddenType::class);
|
||||
$builder->get('socialIssues')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $socialIssuesAsIterable): string {
|
||||
static function (iterable $socialIssuesAsIterable): string {
|
||||
$socialIssueIds = [];
|
||||
|
||||
foreach ($socialIssuesAsIterable as $value) {
|
||||
@ -151,7 +151,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('socialActions', HiddenType::class);
|
||||
$builder->get('socialActions')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $socialActionsAsIterable): string {
|
||||
static function (iterable $socialActionsAsIterable): string {
|
||||
$socialActionIds = [];
|
||||
|
||||
foreach ($socialActionsAsIterable as $value) {
|
||||
@ -203,7 +203,7 @@ class ActivityType extends AbstractType
|
||||
'choice_label' => function (ActivityPresence $activityPresence) {
|
||||
return $this->translatableStringHelper->localize($activityPresence->getName());
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('a')
|
||||
->where('a.active = true');
|
||||
},
|
||||
@ -229,7 +229,7 @@ class ActivityType extends AbstractType
|
||||
return $this->translatableStringHelper->localize($activityReason->getName());
|
||||
},
|
||||
'attr' => ['class' => 'select2 '],
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('a')
|
||||
->where('a.active = true');
|
||||
},
|
||||
@ -248,7 +248,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('persons', HiddenType::class);
|
||||
$builder->get('persons')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $personsAsIterable): string {
|
||||
static function (iterable $personsAsIterable): string {
|
||||
$personIds = [];
|
||||
|
||||
foreach ($personsAsIterable as $value) {
|
||||
@ -270,7 +270,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('thirdParties', HiddenType::class);
|
||||
$builder->get('thirdParties')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $thirdpartyAsIterable): string {
|
||||
static function (iterable $thirdpartyAsIterable): string {
|
||||
$thirdpartyIds = [];
|
||||
|
||||
foreach ($thirdpartyAsIterable as $value) {
|
||||
@ -303,7 +303,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('users', HiddenType::class);
|
||||
$builder->get('users')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $usersAsIterable): string {
|
||||
static function (iterable $usersAsIterable): string {
|
||||
$userIds = [];
|
||||
|
||||
foreach ($usersAsIterable as $value) {
|
||||
@ -325,7 +325,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('location', HiddenType::class)
|
||||
->get('location')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?Location $location): string {
|
||||
static function (?Location $location): string {
|
||||
if (null === $location) {
|
||||
return '';
|
||||
}
|
||||
@ -365,7 +365,7 @@ class ActivityType extends AbstractType
|
||||
->addModelTransformer($durationTimeTransformer);
|
||||
|
||||
$builder->get($fieldName)
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use (
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use (
|
||||
$timeChoices,
|
||||
$builder,
|
||||
$durationTimeTransformer,
|
||||
|
@ -55,7 +55,7 @@ class TranslatableActivityReason extends AbstractType
|
||||
|
||||
return null;
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('r')
|
||||
->where('r.active = true');
|
||||
},
|
||||
|
@ -37,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType
|
||||
[
|
||||
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
||||
'choice_label' => 'name[' . $locale . ']',
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
|
@ -167,7 +167,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
||||
// we get the ids for those scopes
|
||||
$reachablesScopesId = array_map(
|
||||
function (Scope $scope) { return $scope->getId(); },
|
||||
static function (Scope $scope) { return $scope->getId(); },
|
||||
$reachableScopes
|
||||
);
|
||||
|
||||
|
@ -366,8 +366,8 @@ class ActivityControllerTest extends WebTestCase
|
||||
$center
|
||||
);
|
||||
$reachableScopesId = array_intersect(
|
||||
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
);
|
||||
|
||||
if (count($reachableScopesId) === 0) {
|
||||
|
@ -186,7 +186,7 @@ class ActivityTypeTest extends KernelTestCase
|
||||
|
||||
// map all the values in an array
|
||||
$values = array_map(
|
||||
function ($choice) { return $choice->value; },
|
||||
static function ($choice) { return $choice->value; },
|
||||
$view['activity']['durationTime']->vars['choices']
|
||||
);
|
||||
|
||||
|
@ -81,7 +81,7 @@ class TranslatableActivityReasonTest extends TypeTestCase
|
||||
$request->getLocale()->willReturn($fallbackLocale);
|
||||
|
||||
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
|
||||
$requestStack->getCurrentRequest()->will(function () use ($request) {
|
||||
$requestStack->getCurrentRequest()->will(static function () use ($request) {
|
||||
return $request;
|
||||
});
|
||||
|
||||
|
@ -125,7 +125,7 @@ class Configuration implements ConfigurationInterface
|
||||
->info('The number of seconds of this duration. Must be an integer.')
|
||||
->cannotBeEmpty()
|
||||
->validate()
|
||||
->ifTrue(function ($data) {
|
||||
->ifTrue(static function ($data) {
|
||||
return !is_int($data);
|
||||
})->thenInvalid('The value %s is not a valid integer')
|
||||
->end()
|
||||
|
@ -73,7 +73,7 @@ final class AsideActivityFormType extends AbstractType
|
||||
'required' => true,
|
||||
'class' => User::class,
|
||||
'data' => $this->storage->getToken()->getUser(),
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('u')->where('u.enabled = true');
|
||||
},
|
||||
'attr' => ['class' => 'select2 '],
|
||||
@ -98,7 +98,7 @@ final class AsideActivityFormType extends AbstractType
|
||||
'required' => true,
|
||||
'class' => AsideActivityCategory::class,
|
||||
'placeholder' => 'Choose the activity category',
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('ac');
|
||||
$qb->where($qb->expr()->eq('ac.isActive', 'TRUE'))
|
||||
->addOrderBy('ac.ordering', 'ASC');
|
||||
@ -123,7 +123,7 @@ final class AsideActivityFormType extends AbstractType
|
||||
->addModelTransformer($durationTimeTransformer);
|
||||
|
||||
$builder->get($fieldName)
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use (
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use (
|
||||
$timeChoices,
|
||||
$builder,
|
||||
$durationTimeTransformer,
|
||||
|
@ -69,7 +69,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('mainUser', HiddenType::class);
|
||||
$builder->get('mainUser')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?User $user): int {
|
||||
static function (?User $user): int {
|
||||
if (null !== $user) {
|
||||
$res = $user->getId();
|
||||
} else {
|
||||
@ -86,7 +86,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('startDate', HiddenType::class);
|
||||
$builder->get('startDate')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
static function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
if (null !== $dateTimeImmutable) {
|
||||
$res = date_format($dateTimeImmutable, 'Y-m-d H:i:s');
|
||||
} else {
|
||||
@ -95,7 +95,7 @@ class CalendarType extends AbstractType
|
||||
|
||||
return $res;
|
||||
},
|
||||
function (?string $dateAsString): DateTimeImmutable {
|
||||
static function (?string $dateAsString): DateTimeImmutable {
|
||||
dump($dateAsString);
|
||||
|
||||
return new DateTimeImmutable($dateAsString);
|
||||
@ -105,7 +105,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('endDate', HiddenType::class);
|
||||
$builder->get('endDate')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
static function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
if (null !== $dateTimeImmutable) {
|
||||
$res = date_format($dateTimeImmutable, 'Y-m-d H:i:s');
|
||||
} else {
|
||||
@ -114,7 +114,7 @@ class CalendarType extends AbstractType
|
||||
|
||||
return $res;
|
||||
},
|
||||
function (?string $dateAsString): DateTimeImmutable {
|
||||
static function (?string $dateAsString): DateTimeImmutable {
|
||||
return new DateTimeImmutable($dateAsString);
|
||||
}
|
||||
));
|
||||
@ -122,7 +122,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('persons', HiddenType::class);
|
||||
$builder->get('persons')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $personsAsIterable): string {
|
||||
static function (iterable $personsAsIterable): string {
|
||||
$personIds = [];
|
||||
|
||||
foreach ($personsAsIterable as $value) {
|
||||
@ -142,7 +142,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('professionals', HiddenType::class);
|
||||
$builder->get('professionals')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $thirdpartyAsIterable): string {
|
||||
static function (iterable $thirdpartyAsIterable): string {
|
||||
$thirdpartyIds = [];
|
||||
|
||||
foreach ($thirdpartyAsIterable as $value) {
|
||||
@ -162,7 +162,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('calendarRange', HiddenType::class);
|
||||
$builder->get('calendarRange')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?CalendarRange $calendarRange): ?int {
|
||||
static function (?CalendarRange $calendarRange): ?int {
|
||||
if (null !== $calendarRange) {
|
||||
$res = $calendarRange->getId();
|
||||
} else {
|
||||
@ -185,7 +185,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('location', HiddenType::class)
|
||||
->get('location')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?Location $location): string {
|
||||
static function (?Location $location): string {
|
||||
if (null === $location) {
|
||||
return '';
|
||||
}
|
||||
@ -200,7 +200,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('invites', HiddenType::class);
|
||||
$builder->get('invites')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $usersAsIterable): string {
|
||||
static function (iterable $usersAsIterable): string {
|
||||
$userIds = [];
|
||||
|
||||
foreach ($usersAsIterable as $value) {
|
||||
|
@ -137,7 +137,7 @@ class CreateFieldsOnGroupCommand extends Command
|
||||
"Enter the customfieldGroup's id on which the custom fields should be added: "
|
||||
);
|
||||
$question->setNormalizer(
|
||||
function ($answer) use ($customFieldsGroups) {
|
||||
static function ($answer) use ($customFieldsGroups) {
|
||||
foreach ($customFieldsGroups as $customFieldsGroup) {
|
||||
if ($customFieldsGroup->getId() == $answer) {
|
||||
return $customFieldsGroup;
|
||||
@ -237,7 +237,7 @@ class CreateFieldsOnGroupCommand extends Command
|
||||
|
||||
array_walk(
|
||||
$customFieldsGroups,
|
||||
function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) {
|
||||
static function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) {
|
||||
//set id and entity
|
||||
$row = [
|
||||
$customFieldGroup->getId(),
|
||||
|
@ -77,7 +77,7 @@ class CustomFieldDate extends AbstractCustomField
|
||||
|
||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$validatorFunction = function ($value, ExecutionContextInterface $context) {
|
||||
$validatorFunction = static function ($value, ExecutionContextInterface $context) {
|
||||
try {
|
||||
$date = new DateTime($value);
|
||||
} catch (Exception $e) {
|
||||
@ -179,7 +179,7 @@ class CustomFieldDate extends AbstractCustomField
|
||||
// add constraints if required
|
||||
if (null !== $options[self::MIN]) {
|
||||
$fieldOptions['constraints'][] = new Callback(
|
||||
function ($timestamp, ExecutionContextInterface $context) use ($options) {
|
||||
static function ($timestamp, ExecutionContextInterface $context) use ($options) {
|
||||
if (null === $timestamp) {
|
||||
return;
|
||||
}
|
||||
@ -200,7 +200,7 @@ class CustomFieldDate extends AbstractCustomField
|
||||
|
||||
if (null !== $options[self::MAX]) {
|
||||
$fieldOptions['constraints'][] = new Callback(
|
||||
function ($timestamp, ExecutionContextInterface $context) use ($options) {
|
||||
static function ($timestamp, ExecutionContextInterface $context) use ($options) {
|
||||
if (null === $timestamp) {
|
||||
return;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
$translatableStringHelper = $this->translatableStringHelper;
|
||||
$builder->add($customField->getSlug(), Select2ChoiceType::class, [
|
||||
'choices' => $entries,
|
||||
'choice_label' => function (Option $option) use ($translatableStringHelper) {
|
||||
'choice_label' => static function (Option $option) use ($translatableStringHelper) {
|
||||
return $translatableStringHelper->localize($option->getText());
|
||||
},
|
||||
'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(),
|
||||
@ -65,7 +65,7 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
'expanded' => false,
|
||||
'required' => $customField->isRequired(),
|
||||
'placeholder' => 'Choose a value',
|
||||
'group_by' => function (Option $option) use ($translatableStringHelper) {
|
||||
'group_by' => static function (Option $option) use ($translatableStringHelper) {
|
||||
if ($option->hasParent()) {
|
||||
return $translatableStringHelper->localize($option->getParent()->getText());
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class OptionRepository extends EntityRepository
|
||||
->getQuery()
|
||||
->getScalarResult();
|
||||
|
||||
return array_map(function ($r) {
|
||||
return array_map(static function ($r) {
|
||||
return $r['key'];
|
||||
}, $keys);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class CustomFieldType extends AbstractType
|
||||
'label' => 'Required field',
|
||||
])
|
||||
->add('type', HiddenType::class, ['data' => $options['type']])
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event) {
|
||||
$customField = $event->getData();
|
||||
$form = $event->getForm();
|
||||
|
||||
|
@ -55,7 +55,7 @@ class CustomFieldsGroupType extends AbstractType
|
||||
|
||||
$builder->addEventListener(
|
||||
FormEvents::POST_SET_DATA,
|
||||
function (FormEvent $event) use ($customizableEntities, $builder) {
|
||||
static function (FormEvent $event) use ($customizableEntities, $builder) {
|
||||
$form = $event->getForm();
|
||||
$group = $event->getData();
|
||||
|
||||
|
@ -32,7 +32,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
|
||||
|
||||
// @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
|
||||
$customFieldsLablels = array_map(
|
||||
function ($e) { return $e->getLabel(); },
|
||||
static function ($e) { return $e->getLabel(); },
|
||||
$customFields
|
||||
);
|
||||
|
||||
|
@ -30,7 +30,7 @@ class ChoicesListType extends AbstractType
|
||||
'required' => false,
|
||||
])
|
||||
->add('slug', HiddenType::class)
|
||||
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
|
||||
->addEventListener(FormEvents::SUBMIT, static function (FormEvent $event) {
|
||||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
|
@ -59,7 +59,7 @@ class DocGenObjectNormalizer implements NormalizerInterface, NormalizerAwareInte
|
||||
: [];
|
||||
$attributes = array_filter(
|
||||
$metadata->getAttributesMetadata(),
|
||||
function (AttributeMetadata $a) use ($expectedGroups) {
|
||||
static function (AttributeMetadata $a) use ($expectedGroups) {
|
||||
foreach ($a->getGroups() as $g) {
|
||||
if (in_array($g, $expectedGroups, true)) {
|
||||
return true;
|
||||
|
@ -69,7 +69,7 @@ class AccompanyingCourseDocumentType extends AbstractType
|
||||
->add('category', EntityType::class, [
|
||||
'placeholder' => 'Choose a document category',
|
||||
'class' => 'ChillDocStoreBundle:DocumentCategory',
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.documentClass = :docClass')
|
||||
->setParameter('docClass', PersonDocument::class);
|
||||
|
@ -73,7 +73,7 @@ class PersonDocumentType extends AbstractType
|
||||
->add('category', EntityType::class, [
|
||||
'placeholder' => 'Choose a document category',
|
||||
'class' => 'ChillDocStoreBundle:DocumentCategory',
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.documentClass = :docClass')
|
||||
->setParameter('docClass', PersonDocument::class);
|
||||
|
@ -599,7 +599,7 @@ class EventController extends AbstractController
|
||||
$response->setPrivate();
|
||||
$response->headers->addCacheControlDirective('no-cache', true);
|
||||
$response->headers->addCacheControlDirective('must-revalidate', true);
|
||||
$response->setCallback(function () use ($writer) {
|
||||
$response->setCallback(static function () use ($writer) {
|
||||
$writer->save('php://output');
|
||||
});
|
||||
|
||||
|
@ -110,7 +110,7 @@ class ParticipationController extends AbstractController
|
||||
[
|
||||
'event_id' => current($participations)->getEvent()->getId(),
|
||||
'persons_ids' => implode(',', array_map(
|
||||
function (Participation $p) { return $p->getPerson()->getId(); },
|
||||
static function (Participation $p) { return $p->getPerson()->getId(); },
|
||||
$participations
|
||||
)),
|
||||
]
|
||||
@ -646,13 +646,13 @@ class ParticipationController extends AbstractController
|
||||
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
|
||||
$peopleParticipating = $peopleParticipating ??
|
||||
$participation->getEvent()->getParticipations()->map(
|
||||
function (Participation $p) { return $p->getPerson()->getId(); }
|
||||
static function (Participation $p) { return $p->getPerson()->getId(); }
|
||||
);
|
||||
// check that the user is not already in the event
|
||||
if ($peopleParticipating->contains($participation->getPerson()->getId())) {
|
||||
$ignoredParticipations[] = $participation
|
||||
->getEvent()->getParticipations()->filter(
|
||||
function (Participation $p) use ($participation) {
|
||||
static function (Participation $p) use ($participation) {
|
||||
return $p->getPerson()->getId() === $participation->getPerson()->getId();
|
||||
}
|
||||
)->first();
|
||||
|
@ -174,7 +174,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
$iterator = $this->participations->getIterator();
|
||||
|
||||
$iterator->uasort(function ($first, $second) {
|
||||
$iterator->uasort(static function ($first, $second) {
|
||||
return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName());
|
||||
});
|
||||
|
||||
|
@ -59,7 +59,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedEvents,
|
||||
function (Event $p) use ($value) {
|
||||
static function (Event $p) use ($value) {
|
||||
return call_user_func($value, $p);
|
||||
}
|
||||
);
|
||||
|
@ -106,14 +106,14 @@ class PickEventType extends AbstractType
|
||||
// add the default options
|
||||
$resolver->setDefaults([
|
||||
'class' => Event::class,
|
||||
'choice_label' => function (Event $e) {
|
||||
'choice_label' => static function (Event $e) {
|
||||
return $e->getDate()->format('d/m/Y, H:i') . ' → ' .
|
||||
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
|
||||
$e->getName();
|
||||
},
|
||||
'placeholder' => 'Pick an event',
|
||||
'attr' => ['class' => 'select2 '],
|
||||
'choice_attr' => function (Event $e) {
|
||||
'choice_attr' => static function (Event $e) {
|
||||
return ['data-center' => $e->getCenter()->getId()];
|
||||
},
|
||||
'choiceloader' => function (Options $options) {
|
||||
@ -140,7 +140,7 @@ class PickEventType extends AbstractType
|
||||
// option role
|
||||
if (null === $options['role']) {
|
||||
$centers = array_map(
|
||||
function (GroupCenter $g) {
|
||||
static function (GroupCenter $g) {
|
||||
return $g->getCenter();
|
||||
},
|
||||
$this->user->getGroupCenters()->toArray()
|
||||
@ -169,7 +169,7 @@ class PickEventType extends AbstractType
|
||||
}
|
||||
|
||||
if (!in_array($c->getId(), array_map(
|
||||
function (Center $c) { return $c->getId(); },
|
||||
static function (Center $c) { return $c->getId(); },
|
||||
$centers
|
||||
))) {
|
||||
throw new AccessDeniedException('The given center is not reachable');
|
||||
|
@ -37,14 +37,14 @@ class PickEventTypeType extends AbstractType
|
||||
$resolver->setDefaults(
|
||||
[
|
||||
'class' => EventType::class,
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('et')
|
||||
->where('et.active = true');
|
||||
},
|
||||
'choice_label' => function (EventType $t) use ($helper) {
|
||||
'choice_label' => static function (EventType $t) use ($helper) {
|
||||
return $helper->localize($t->getName());
|
||||
},
|
||||
'choice_attrs' => function (EventType $t) {
|
||||
'choice_attrs' => static function (EventType $t) {
|
||||
return ['data-link-category' => $t->getId()];
|
||||
},
|
||||
]
|
||||
|
@ -109,13 +109,13 @@ class PickRoleType extends AbstractType
|
||||
'class' => Role::class,
|
||||
'query_builder' => $qb,
|
||||
'group_by' => null,
|
||||
'choice_attr' => function (Role $r) {
|
||||
'choice_attr' => static function (Role $r) {
|
||||
return [
|
||||
'data-event-type' => $r->getType()->getId(),
|
||||
'data-link-category' => $r->getType()->getId(),
|
||||
];
|
||||
},
|
||||
'choice_label' => function (Role $r) use ($translatableStringHelper, $translator) {
|
||||
'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) {
|
||||
return $translatableStringHelper->localize($r->getName()) .
|
||||
($r->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')');
|
||||
|
@ -110,13 +110,13 @@ class PickStatusType extends AbstractType
|
||||
'class' => Status::class,
|
||||
'query_builder' => $qb,
|
||||
'group_by' => null,
|
||||
'choice_attr' => function (Status $s) {
|
||||
'choice_attr' => static function (Status $s) {
|
||||
return [
|
||||
'data-event-type' => $s->getType()->getId(),
|
||||
'data-link-category' => $s->getType()->getId(),
|
||||
];
|
||||
},
|
||||
'choice_label' => function (Status $s) use ($translatableStringHelper, $translator) {
|
||||
'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) {
|
||||
return $translatableStringHelper->localize($s->getName()) .
|
||||
($s->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')');
|
||||
|
@ -237,7 +237,7 @@ class ParticipationControllerTest extends WebTestCase
|
||||
$this->personsIdsCache = array_merge(
|
||||
$this->personsIdsCache,
|
||||
$event->getParticipations()->map(
|
||||
function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
)
|
||||
->toArray()
|
||||
);
|
||||
@ -301,7 +301,7 @@ class ParticipationControllerTest extends WebTestCase
|
||||
$event = $this->getRandomEventWithMultipleParticipations();
|
||||
|
||||
$persons_id = implode(',', $event->getParticipations()->map(
|
||||
function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
)->toArray());
|
||||
|
||||
$crawler = $this->client->request(
|
||||
@ -327,7 +327,7 @@ class ParticipationControllerTest extends WebTestCase
|
||||
$nbParticipations = $event->getParticipations()->count();
|
||||
// get the persons_id participating on this event
|
||||
$persons_id = $event->getParticipations()->map(
|
||||
function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
)->toArray();
|
||||
// exclude the existing persons_ids from the new person
|
||||
$this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id);
|
||||
@ -456,7 +456,7 @@ class ParticipationControllerTest extends WebTestCase
|
||||
|
||||
$circles = $this->em->getRepository('ChillMainBundle:Scope')
|
||||
->findAll();
|
||||
array_filter($circles, function ($circle) use ($circleName) {
|
||||
array_filter($circles, static function ($circle) use ($circleName) {
|
||||
return in_array($circleName, $circle->getName());
|
||||
});
|
||||
$circle = $circles[0];
|
||||
|
@ -365,7 +365,7 @@ class EventSearchTest extends WebTestCase
|
||||
'décembre' => 12,
|
||||
];
|
||||
|
||||
$results = $trs->each(function ($tr, $i) use ($months) {
|
||||
$results = $trs->each(static function ($tr, $i) use ($months) {
|
||||
// we skip the first row
|
||||
if (0 < $i) {
|
||||
// get the second node, which should contains a date
|
||||
|
@ -206,7 +206,7 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
$reachableCircleId = array_map(
|
||||
function (Scope $scope) { return $scope->getId(); },
|
||||
static function (Scope $scope) { return $scope->getId(); },
|
||||
$this->helper->getReachableCircles($this->user, $role, $person->getCenter())
|
||||
);
|
||||
$centerAndScopeLines[] = sprintf(
|
||||
|
@ -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];
|
||||
});
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ final class ImportPeopleFromCSVCommand extends Command
|
||||
}
|
||||
|
||||
$centersByName = [];
|
||||
$names = array_map(function (Center $c) use (&$centersByName) {
|
||||
$names = array_map(static function (Center $c) use (&$centersByName) {
|
||||
$n = $c->getName();
|
||||
$centersByName[$n] = $c;
|
||||
|
||||
@ -609,7 +609,7 @@ final class ImportPeopleFromCSVCommand extends Command
|
||||
}
|
||||
|
||||
$postalCodeByName = [];
|
||||
$names = array_map(function (PostalCode $pc) use (&$postalCodeByName) {
|
||||
$names = array_map(static function (PostalCode $pc) use (&$postalCodeByName) {
|
||||
$n = $pc->getName();
|
||||
$postalCodeByName[$n] = $pc;
|
||||
|
||||
@ -859,7 +859,7 @@ final class ImportPeopleFromCSVCommand extends Command
|
||||
if (!isset($this->cacheAnswersMapping[$cf->getSlug()][$value])) {
|
||||
// try to find the answer (with array_keys and a search value
|
||||
$values = array_keys(
|
||||
array_map(function ($label) { return trim(strtolower($label)); }, $answers),
|
||||
array_map(static function ($label) { return trim(strtolower($label)); }, $answers),
|
||||
trim(strtolower($value)),
|
||||
true
|
||||
);
|
||||
|
@ -322,7 +322,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
/** @var AccompanyingPeriod $period */
|
||||
$period = array_filter(
|
||||
$person->getAccompanyingPeriods(),
|
||||
function (AccompanyingPeriod $p) use ($period_id) {
|
||||
static function (AccompanyingPeriod $p) use ($period_id) {
|
||||
return $p->getId() === ($period_id);
|
||||
}
|
||||
)[0] ?? null;
|
||||
|
@ -106,7 +106,7 @@ class HouseholdApiController extends ApiController
|
||||
$actual = $household->getCurrentAddress();
|
||||
|
||||
if (null !== $actual) {
|
||||
$addresses = array_filter($addresses, fn ($a) => $a !== $actual);
|
||||
$addresses = array_filter($addresses, static fn ($a) => $a !== $actual);
|
||||
}
|
||||
|
||||
return $this->json(
|
||||
|
@ -62,7 +62,7 @@ class PersonApiController extends ApiController
|
||||
$actual = $person->getCurrentHouseholdAddress();
|
||||
|
||||
if (null !== $actual) {
|
||||
$addresses = array_filter($addresses, fn ($a) => $a !== $actual);
|
||||
$addresses = array_filter($addresses, static fn ($a) => $a !== $actual);
|
||||
}
|
||||
|
||||
return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
|
@ -113,7 +113,7 @@ class LoadCustomFields extends AbstractFixture implements
|
||||
|
||||
// get possible values for cfGroup
|
||||
$choices = array_map(
|
||||
function ($a) { return $a['slug']; },
|
||||
static function ($a) { return $a['slug']; },
|
||||
$this->customFieldChoice->getOptions()['choices']
|
||||
);
|
||||
// create faker
|
||||
|
@ -44,7 +44,7 @@ class Configuration implements ConfigurationInterface
|
||||
->info($this->validationBirthdateNotAfterInfos)
|
||||
->defaultValue('P1D')
|
||||
->validate()
|
||||
->ifTrue(function ($period) {
|
||||
->ifTrue(static function ($period) {
|
||||
try {
|
||||
$interval = new DateInterval($period);
|
||||
} catch (Exception $ex) {
|
||||
|
@ -520,10 +520,10 @@ class AccompanyingPeriod implements
|
||||
public function getAvailablePersonLocation(): Collection
|
||||
{
|
||||
return $this->getOpenParticipations()
|
||||
->filter(function (AccompanyingPeriodParticipation $p) {
|
||||
->filter(static function (AccompanyingPeriodParticipation $p) {
|
||||
return $p->getPerson()->hasCurrentHouseholdAddress();
|
||||
})
|
||||
->map(function (AccompanyingPeriodParticipation $p) {
|
||||
->map(static function (AccompanyingPeriodParticipation $p) {
|
||||
return $p->getPerson();
|
||||
});
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class Household
|
||||
{
|
||||
$at = null === $at ? new DateTime('today') : $at;
|
||||
|
||||
$addrs = $this->getAddresses()->filter(function (Address $a) use ($at) {
|
||||
$addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) {
|
||||
return $a->getValidFrom() <= $at && (
|
||||
null === $a->getValidTo() || $a->getValidTo() > $at
|
||||
);
|
||||
@ -178,7 +178,7 @@ class Household
|
||||
public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)->map(
|
||||
fn (HouseholdMember $m) => $m->getId()
|
||||
static fn (HouseholdMember $m) => $m->getId()
|
||||
);
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ class Household
|
||||
|
||||
$members->getIterator()
|
||||
->uasort(
|
||||
function (HouseholdMember $a, HouseholdMember $b) {
|
||||
static function (HouseholdMember $a, HouseholdMember $b) {
|
||||
if ($a->getPosition() === null) {
|
||||
if ($b->getPosition() === null) {
|
||||
return 0;
|
||||
@ -247,7 +247,7 @@ class Household
|
||||
public function getCurrentPersons(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)
|
||||
->map(function (HouseholdMember $m) { return $m->getPerson(); });
|
||||
->map(static function (HouseholdMember $m) { return $m->getPerson(); });
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@ -269,7 +269,7 @@ class Household
|
||||
$membership->getStartDate(),
|
||||
$membership->getEndDate()
|
||||
)->filter(
|
||||
function (HouseholdMember $m) use ($membership) {
|
||||
static function (HouseholdMember $m) use ($membership) {
|
||||
return $m !== $membership;
|
||||
}
|
||||
);
|
||||
|
@ -774,7 +774,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$periods = $this->getAccompanyingPeriods();
|
||||
|
||||
//order by date :
|
||||
usort($periods, function ($a, $b) {
|
||||
usort($periods, static function ($a, $b) {
|
||||
$dateA = $a->getOpeningDate();
|
||||
$dateB = $b->getOpeningDate();
|
||||
|
||||
@ -1296,7 +1296,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
return $this->getAccompanyingPeriodParticipations()
|
||||
->matching($criteria)
|
||||
->filter(function (AccompanyingPeriodParticipation $app) {
|
||||
->filter(static function (AccompanyingPeriodParticipation $app) {
|
||||
return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep();
|
||||
});
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme
|
||||
];
|
||||
}
|
||||
|
||||
return function (string $value) use ($labels): string {
|
||||
return static function (string $value) use ($labels): string {
|
||||
return $labels[$value];
|
||||
};
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV
|
||||
];
|
||||
}
|
||||
|
||||
return function (string $value) use ($labels): string {
|
||||
return static function (string $value) use ($labels): string {
|
||||
return $labels[$value];
|
||||
};
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class CountPerson implements ExportInterface
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return function ($value) use ($labels) {
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
}
|
||||
@ -88,7 +88,7 @@ class CountPerson implements ExportInterface
|
||||
*/
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(function ($el) { return $el['center']; }, $acl);
|
||||
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@ -102,7 +102,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
|
||||
return [];
|
||||
},
|
||||
'constraints' => [new Callback([
|
||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||
if (count($selected) === 0) {
|
||||
$context->buildViolation('You must select at least one element')
|
||||
->atPath('fields')
|
||||
@ -266,7 +266,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(function ($el) { return $el['center']; }, $acl);
|
||||
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
|
@ -63,7 +63,7 @@ class GenderFilter implements
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('person_gender', array_filter(
|
||||
$data['accepted_genders'],
|
||||
function ($el) {
|
||||
static function ($el) {
|
||||
return 'null' !== $el;
|
||||
}
|
||||
));
|
||||
|
@ -52,7 +52,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPersons,
|
||||
function (Person $p) use ($value) {
|
||||
static function (Person $p) use ($value) {
|
||||
return call_user_func($value, $p);
|
||||
}
|
||||
);
|
||||
|
@ -111,10 +111,10 @@ class PersonType extends AbstractType
|
||||
]);
|
||||
|
||||
$builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer(
|
||||
function ($string) {
|
||||
static function ($string) {
|
||||
return strtoupper($string);
|
||||
},
|
||||
function ($string) {
|
||||
static function ($string) {
|
||||
return strtoupper($string);
|
||||
}
|
||||
));
|
||||
@ -148,7 +148,7 @@ class PersonType extends AbstractType
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'label' => false,
|
||||
'delete_empty' => function (?PersonPhone $pp = null) {
|
||||
'delete_empty' => static function (?PersonPhone $pp = null) {
|
||||
return null === $pp || $pp->isEmpty();
|
||||
},
|
||||
'error_bubbling' => false,
|
||||
@ -192,7 +192,7 @@ class PersonType extends AbstractType
|
||||
'choice_label' => function (Civility $civility): string {
|
||||
return $this->translatableStringHelper->localize($civility->getName());
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er): QueryBuilder {
|
||||
'query_builder' => static function (EntityRepository $er): QueryBuilder {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
|
@ -110,11 +110,11 @@ class PickPersonType extends AbstractType
|
||||
// add the default options
|
||||
$resolver->setDefaults([
|
||||
'class' => Person::class,
|
||||
'choice_label' => function (Person $p) {
|
||||
'choice_label' => static function (Person $p) {
|
||||
return $p->getFirstname() . ' ' . $p->getLastname();
|
||||
},
|
||||
'placeholder' => 'Pick a person',
|
||||
'choice_attr' => function (Person $p) {
|
||||
'choice_attr' => static function (Person $p) {
|
||||
return [
|
||||
'data-center' => $p->getCenter()->getId(),
|
||||
];
|
||||
@ -136,7 +136,7 @@ class PickPersonType extends AbstractType
|
||||
protected function filterCentersfom(Options $options)
|
||||
{
|
||||
if (null === $options['role']) {
|
||||
$centers = array_map(function (GroupCenter $g) {
|
||||
$centers = array_map(static function (GroupCenter $g) {
|
||||
return $g->getCenter();
|
||||
}, $this->user->getGroupCenters()->toArray());
|
||||
} else {
|
||||
@ -160,7 +160,7 @@ class PickPersonType extends AbstractType
|
||||
}
|
||||
|
||||
if (!in_array($c->getId(), array_map(
|
||||
function (Center $c) { return $c->getId(); },
|
||||
static function (Center $c) { return $c->getId(); },
|
||||
$centers
|
||||
))) {
|
||||
throw new AccessDeniedException('The given center is not reachable');
|
||||
|
@ -73,7 +73,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
$involved = $this->getInvolved();
|
||||
$involved['period_id'] = $event->getPeriod()->getId();
|
||||
$involved['persons'] = $event->getPeriod()->getPersons()
|
||||
->map(function (Person $p) { return $p->getId(); })
|
||||
->map(static function (Person $p) { return $p->getId(); })
|
||||
->toArray();
|
||||
|
||||
$this->logger->notice(
|
||||
@ -97,7 +97,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
|
||||
if ($event->hasPersons()) {
|
||||
$involved['persons'] = array_map(
|
||||
function (Person $p) { return $p->getId(); },
|
||||
static function (Person $p) { return $p->getId(); },
|
||||
$event->getPersons()
|
||||
);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
|
||||
),
|
||||
]
|
||||
),
|
||||
array_map(function (Center $c) {return $c->getId(); }, $authorizedCenters)
|
||||
array_map(static function (Center $c) {return $c->getId(); }, $authorizedCenters)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
'persons' => $this->search($terms, $start, $limit, $options),
|
||||
'pattern' => $this->recomposePattern(
|
||||
$terms,
|
||||
array_filter(self::POSSIBLE_KEYS, fn ($item) => '_default' !== $item),
|
||||
array_filter(self::POSSIBLE_KEYS, static fn ($item) => '_default' !== $item),
|
||||
$terms['_domain']
|
||||
),
|
||||
'total' => $total,
|
||||
|
@ -58,7 +58,7 @@ class SearchPersonApiProvider 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->personRepository->findByIds($ids);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class AccompanyingPeriodWorkDenormalizer implements DenormalizerAwareInterface,
|
||||
// partition the separate kept evaluations and removed one
|
||||
[$kept, $removed] = $work->getAccompanyingPeriodWorkEvaluations()
|
||||
->partition(
|
||||
fn (int $key, AccompanyingPeriodWorkEvaluation $a) => array_key_exists($a->getId(), $dataById)
|
||||
static fn (int $key, AccompanyingPeriodWorkEvaluation $a) => array_key_exists($a->getId(), $dataById)
|
||||
);
|
||||
|
||||
// remove the evaluations from work
|
||||
|
@ -61,7 +61,7 @@ class PersonDocGenNormalizer implements
|
||||
'altNames' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
function (PersonAltName $altName) {
|
||||
static function (PersonAltName $altName) {
|
||||
return $altName->getLabel();
|
||||
},
|
||||
$person->getAltNames()->toArray()
|
||||
|
@ -33,7 +33,7 @@ class SocialIssueNormalizer implements NormalizerInterface, NormalizerAwareInter
|
||||
'type' => 'social_issue',
|
||||
'id' => $socialIssue->getId(),
|
||||
'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null,
|
||||
'children_ids' => $socialIssue->getChildren()->map(function (SocialIssue $si) { return $si->getId(); }),
|
||||
'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }),
|
||||
'title' => $socialIssue->getTitle(),
|
||||
'text' => $this->render->renderString($socialIssue, []),
|
||||
];
|
||||
|
@ -329,7 +329,7 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
|
||||
// check that the person id is contained
|
||||
$participationsPersonsIds = array_map(
|
||||
function ($participation) { return $participation->person->id; },
|
||||
static function ($participation) { return $participation->person->id; },
|
||||
$data->participations
|
||||
);
|
||||
|
||||
|
@ -151,7 +151,7 @@ class HouseholdApiControllerTest extends WebTestCase
|
||||
$this->assertArrayHasKey('count', $data);
|
||||
$this->assertArrayHasKey('results', $data);
|
||||
|
||||
$householdIds = array_map(function ($r) {
|
||||
$householdIds = array_map(static function ($r) {
|
||||
return $r['id'];
|
||||
}, $data['results']);
|
||||
|
||||
|
@ -290,22 +290,22 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
public function validTextFieldsProvider()
|
||||
{
|
||||
return [
|
||||
['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }],
|
||||
['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
|
||||
// reminder: this value is capitalized
|
||||
['placeOfBirth', 'A PLACE', function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '1980-12-15', function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
|
||||
['phonenumber', '+32123456789', function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', 'BE', function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
|
||||
['nationality', 'FR', function (Person $person) { return $person->getNationality()->getCountryCode(); }],
|
||||
['placeOfBirth', '', function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '', function (Person $person) { return $person->getBirthdate(); }],
|
||||
['phonenumber', '', function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', '', function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', null, function (Person $person) { return $person->getCountryOfBirth(); }],
|
||||
['nationality', null, function (Person $person) { return $person->getNationality(); }],
|
||||
['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }],
|
||||
['placeOfBirth', 'A PLACE', static function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '1980-12-15', static function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
|
||||
['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', 'BE', static function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
|
||||
['nationality', 'FR', static function (Person $person) { return $person->getNationality()->getCountryCode(); }],
|
||||
['placeOfBirth', '', static function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
|
||||
['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', '', static function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', null, static function (Person $person) { return $person->getCountryOfBirth(); }],
|
||||
['nationality', null, static function (Person $person) { return $person->getNationality(); }],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -195,12 +195,12 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
|
||||
public function validTextFieldsProvider()
|
||||
{
|
||||
return [
|
||||
['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }],
|
||||
['birthdate', '15-12-1980', function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }],
|
||||
['birthdate', '', function (Person $person) { return $person->getBirthdate(); }],
|
||||
['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }],
|
||||
['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
|
||||
['birthdate', '15-12-1980', static function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
|
||||
['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
$prophecy = $this->prophesize(CenterResolverManagerInterface::class);
|
||||
|
||||
$prophecy->resolveCenters(Argument::type(Person::class), Argument::any())->will(function ($args) {
|
||||
$prophecy->resolveCenters(Argument::type(Person::class), Argument::any())->will(static function ($args) {
|
||||
$center = $args[0]->getCenter();
|
||||
|
||||
if ($center instanceof Center) {
|
||||
|
@ -100,7 +100,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
'expanded' => true,
|
||||
'choices' => $choices,
|
||||
'label' => 'Fields to include in export',
|
||||
'choice_attr' => function ($val, $key, $index) {
|
||||
'choice_attr' => static function ($val, $key, $index) {
|
||||
// add a 'data-display-target' for address fields
|
||||
if (substr($val, 0, 8) === 'address_') {
|
||||
return ['data-display-target' => 'address_date'];
|
||||
@ -124,7 +124,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
}
|
||||
},
|
||||
'constraints' => [new Callback([
|
||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||
if (count($selected) === 0) {
|
||||
$context->buildViolation('You must select at least one element')
|
||||
->atPath('fields')
|
||||
@ -165,7 +165,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
case 'report_date':
|
||||
// for birthdate or report date, we have to transform the string into a date
|
||||
// to format the date correctly.
|
||||
return function ($value) use ($key) {
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'person_birthdate' === $key ? 'birthdate' : 'report_date';
|
||||
}
|
||||
@ -202,7 +202,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
$scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']);
|
||||
}
|
||||
|
||||
return function ($value) use ($scopes): string {
|
||||
return static function ($value) use ($scopes): string {
|
||||
if ('_header' === $value) {
|
||||
return 'circle';
|
||||
}
|
||||
@ -224,7 +224,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
$users[$row['id']] = $row['username'];
|
||||
}
|
||||
|
||||
return function ($value) use ($users): string {
|
||||
return static function ($value) use ($users): string {
|
||||
if ('_header' === $value) {
|
||||
return 'user';
|
||||
}
|
||||
@ -282,7 +282,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
default:
|
||||
// for fields which are associated with person
|
||||
if (in_array($key, $this->fields)) {
|
||||
return function ($value) use ($key) {
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return strtolower($key);
|
||||
}
|
||||
@ -331,7 +331,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(function ($el) { return $el['center']; }, $acl);
|
||||
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
@ -503,7 +503,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
private function getCustomFields()
|
||||
{
|
||||
return array_filter($this->customfieldsGroup
|
||||
->getCustomFields()->toArray(), function (CustomField $cf) {
|
||||
->getCustomFields()->toArray(), static function (CustomField $cf) {
|
||||
return $cf->getType() !== 'title';
|
||||
});
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
$reachableScopesId = array_map(
|
||||
function (Scope $scope) { return $scope->getId(); },
|
||||
static function (Scope $scope) { return $scope->getId(); },
|
||||
$this->helper->getReachableScopes($this->user, $role, $center)
|
||||
);
|
||||
$whereElement->add(
|
||||
|
@ -66,7 +66,7 @@ class ReportControllerNextTest extends WebTestCase
|
||||
//filter customFieldsGroup to get only "situation de logement"
|
||||
$filteredCustomFieldsGroupHouse = array_filter(
|
||||
$customFieldsGroups,
|
||||
function (CustomFieldsGroup $group) {
|
||||
static function (CustomFieldsGroup $group) {
|
||||
return in_array('Situation de logement', $group->getName());
|
||||
}
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ class ReportControllerTest extends WebTestCase
|
||||
//filter customFieldsGroup to get only "situation de logement"
|
||||
$filteredCustomFieldsGroupHouse = array_filter(
|
||||
$customFieldsGroups,
|
||||
function (CustomFieldsGroup $group) {
|
||||
static function (CustomFieldsGroup $group) {
|
||||
return in_array('Situation de logement', $group->getName());
|
||||
}
|
||||
);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user