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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user