DX: rector rules upt to PHP 74

This commit is contained in:
2023-04-15 00:20:19 +02:00
parent a68190f0c6
commit 858ade467c
213 changed files with 433 additions and 1052 deletions

View File

@@ -230,7 +230,7 @@ class CRUDController extends AbstractController
*/
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
$formClass = $formClass ?? $this->getFormClassFor($action);
$formClass ??= $this->getFormClassFor($action);
$form = $this->createForm($formClass, $entity, $formOptions);

View File

@@ -141,9 +141,7 @@ class CRUDRoutesLoader extends Loader
$methods = array_keys(array_filter(
$action['methods'],
static function ($value, $key) {
return $value;
},
static fn($value, $key) => $value,
ARRAY_FILTER_USE_BOTH
));

View File

@@ -282,9 +282,7 @@ class NotificationController extends AbstractController
if ($request->query->has('edit')) {
$commentId = $request->query->getInt('edit');
$editedComment = $notification->getComments()->filter(static function (NotificationComment $c) use ($commentId) {
return $c->getId() === $commentId;
})->first();
$editedComment = $notification->getComments()->filter(static fn(NotificationComment $c) => $c->getId() === $commentId)->first();
if (false === $editedComment) {
throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification");

View File

@@ -158,9 +158,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(static function ($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(),
]);
}
@@ -305,9 +303,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(static function ($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(),
]);
}
@@ -449,9 +445,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(static function ($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(),
]);
}
@@ -573,9 +567,7 @@ class PermissionsGroupController extends AbstractController
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
$expandedRoles[$roleScope->getRole()] =
array_map(
static function (Role $role) {
return $role->getRole();
},
static fn(Role $role) => $role->getRole(),
$this->roleHierarchy
->getReachableRoles(
[new Role($roleScope->getRole())]

View File

@@ -337,9 +337,7 @@ class UserController extends CRUDController
[
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(),
'delete_groupcenter_form' => array_map(
static function (Form $form) {
return $form->createView();
},
static fn(Form $form) => $form->createView(),
iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true)
),
]

View File

@@ -345,12 +345,10 @@ class WorkflowController extends AbstractController
if ($transitionForm->isSubmitted() && $transitionForm->isValid()) {
if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) {
$blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition);
$msgs = array_map(function (TransitionBlocker $tb) {
return $this->translator->trans(
$tb->getMessage(),
$tb->getParameters()
);
}, iterator_to_array($blockers));
$msgs = array_map(fn(TransitionBlocker $tb) => $this->translator->trans(
$tb->getMessage(),
$tb->getParameters()
), iterator_to_array($blockers));
throw $this->createAccessDeniedException(
sprintf(

View File

@@ -37,9 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface
];
}
usort($services, static function ($a, $b) {
return $a['priority'] <=> $b['priority'];
});
usort($services, static fn($a, $b) => $a['priority'] <=> $b['priority']);
foreach ($services as $service) {
$class = $container->getDefinition($service['id'])->getClass();

View File

@@ -33,9 +33,7 @@ class Greatest extends FunctionNode
public function getSql(SqlWalker $sqlWalker)
{
return 'GREATEST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) {
return $expr->dispatch($sqlWalker);
}, $this->exprs)) . ')';
return 'GREATEST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
}
public function parse(Parser $parser)

View File

@@ -33,9 +33,7 @@ class Least extends FunctionNode
public function getSql(SqlWalker $sqlWalker)
{
return 'LEAST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) {
return $expr->dispatch($sqlWalker);
}, $this->exprs)) . ')';
return 'LEAST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
}
public function parse(Parser $parser)

View File

@@ -149,7 +149,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @Groups({"write"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private ?ThirdParty $linkedToThirdParty;
private ?ThirdParty $linkedToThirdParty = null;
/**
* A geospatial field storing the coordinates of the Address.

View File

@@ -55,7 +55,7 @@ class AddressReference
* @ORM\Column(type="integer")
* @groups({"read"})
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
@@ -79,7 +79,7 @@ class AddressReference
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
* @groups({"read"})
*/
private ?PostalCode $postcode;
private ?PostalCode $postcode = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})

View File

@@ -36,7 +36,7 @@ class GeographicalUnit
/**
* @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units")
*/
private ?GeographicalUnitLayer $layer;
private ?GeographicalUnitLayer $layer = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})

View File

@@ -120,12 +120,12 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private ?DateTimeImmutable $updatedAt;
private ?DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private ?User $updatedBy;
private ?User $updatedBy = null;
public function __construct()
{

View File

@@ -121,9 +121,7 @@ class PermissionsGroup
public function isRoleScopePresentOnce(ExecutionContextInterface $context)
{
$roleScopesId = array_map(
static function (RoleScope $roleScope) {
return $roleScope->getId();
},
static fn(RoleScope $roleScope) => $roleScope->getId(),
$this->getRoleScopes()->toArray()
);
$countedIds = array_count_values($roleScopesId);

View File

@@ -291,9 +291,7 @@ class EntityWorkflowStep
public function removeDestEmail(string $email): self
{
$this->destEmail = array_filter($this->destEmail, static function (string $existing) use ($email) {
return $email !== $existing;
});
$this->destEmail = array_filter($this->destEmail, static fn(string $existing) => $email !== $existing);
return $this;
}

View File

@@ -199,9 +199,7 @@ class CSVListFormatter implements FormatterInterface
foreach ($keys as $key) {
// get an array with all values for this key if possible
$values = array_map(static function ($v) use ($key) {
return $v[$key];
}, $this->result);
$values = array_map(static fn($v) => $v[$key], $this->result);
// store the label in the labelsCache property
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
}

View File

@@ -187,9 +187,7 @@ class CSVPivotedListFormatter implements FormatterInterface
foreach ($keys as $key) {
// get an array with all values for this key if possible
$values = array_map(static function ($v) use ($key) {
return $v[$key];
}, $this->result);
$values = array_map(static fn($v) => $v[$key], $this->result);
// store the label in the labelsCache property
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
}

View File

@@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->initializeCache($key);
}
$value = $value ?? '';
$value ??= '';
return call_user_func($this->cacheDisplayableResult[$key], $value);
}

View File

@@ -249,7 +249,7 @@ class ExportAddressHelper
if (($params & $bitmask) === $bitmask) {
if ('geographical_units' === $key) {
// geographical unit generate keys dynamically, depending on layers
$prefixes = array_merge($prefixes, array_keys($this->generateKeysForUnitsNames($prefix)), array_keys($this->generateKeysForUnitsRefs($prefix)));
$prefixes = [...$prefixes, ...array_keys($this->generateKeysForUnitsNames($prefix)), ...array_keys($this->generateKeysForUnitsRefs($prefix))];
continue;
}
@@ -257,9 +257,7 @@ class ExportAddressHelper
$prefixes = array_merge(
$prefixes,
array_map(
static function ($item) use ($prefix) {
return $prefix . $item;
},
static fn($item) => $prefix . $item,
self::COLUMN_MAPPING[$key]
)
);

View File

@@ -48,9 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
{
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedPostalCodes,
static function (?PostalCode $pc = null) use ($value) {
return call_user_func($value, $pc);
}
static fn(?PostalCode $pc = null) => call_user_func($value, $pc)
);
}

View File

@@ -37,9 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
/** @phpstan-ignore-next-line */
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool {
return false;
});
[$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false);
if (0 === count($notContained)) {
$pickedRegroupment[] = $regroupment;

View File

@@ -42,9 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{
$this->repository = $repository;
$this->multiple = $multiple;
$this->getId = $getId ?? static function (object $o) {
return $o->getId();
};
$this->getId = $getId ?? static fn(object $o) => $o->getId();
}
/**

View File

@@ -36,15 +36,11 @@ final class LocationFormType extends AbstractType
$builder
->add('locationType', EntityType::class, [
'class' => EntityLocationType::class,
'choice_attr' => static function (EntityLocationType $entity) {
return [
'data-address' => $entity->getAddressRequired(),
'data-contact' => $entity->getContactData(),
];
},
'choice_label' => function (EntityLocationType $entity) {
return $this->translatableStringHelper->localize($entity->getTitle());
},
'choice_attr' => static fn(EntityLocationType $entity) => [
'data-address' => $entity->getAddressRequired(),
'data-contact' => $entity->getContactData(),
],
'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()),
])
->add('name', TextType::class)
->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false])

View File

@@ -24,14 +24,10 @@ class ComposedGroupCenterType extends AbstractType
{
$builder->add('permissionsgroup', EntityType::class, [
'class' => \Chill\MainBundle\Entity\PermissionsGroup::class,
'choice_label' => static function (PermissionsGroup $group) {
return $group->getName();
},
'choice_label' => static fn(PermissionsGroup $group) => $group->getName(),
])->add('center', EntityType::class, [
'class' => \Chill\MainBundle\Entity\Center::class,
'choice_label' => static function (Center $center) {
return $center->getName();
},
'choice_label' => static fn(Center $center) => $center->getName(),
]);
}

View File

@@ -82,15 +82,11 @@ class ComposedRoleScopeType extends AbstractType
return ['data-has-scope' => '1'];
},
'group_by' => function ($role, $key, $index) {
return $this->roleProvider->getRoleTitle($role);
},
'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role),
])
->add('scope', EntityType::class, [
'class' => Scope::class,
'choice_label' => static function (Scope $scope) use ($translatableStringHelper) {
return $translatableStringHelper->localize($scope->getName());
},
'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()),
'required' => false,
'data' => null,
]);

View File

@@ -51,9 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
}
return array_map(
function ($item) {
return $this->denormalizeOne($item);
},
fn($item) => $this->denormalizeOne($item),
$denormalized
);
}

View File

@@ -67,9 +67,7 @@ final class PickCenterType extends AbstractType
'choices' => $centers,
'multiple' => true,
'expanded' => true,
'choice_label' => static function (Center $c) {
return $c->getName();
},
'choice_label' => static fn(Center $c) => $c->getName(),
'data' => $centers,
]);
@@ -80,9 +78,7 @@ final class PickCenterType extends AbstractType
'multiple' => true,
'expanded' => true,
'choices' => $this->regroupmentRepository->findAllActive(),
'choice_label' => static function (Regroupment $r) {
return $r->getName();
},
'choice_label' => static fn(Regroupment $r) => $r->getName(),
]);
}

View File

@@ -90,9 +90,7 @@ class PickCenterType extends AbstractType
return ['center' => $data];
},
static function ($data) {
return $data['center'];
}
static fn($data) => $data['center']
));
}

View File

@@ -34,17 +34,13 @@ class PickCivilityType extends AbstractType
->setDefault('label', 'Civility')
->setDefault(
'choice_label',
function (Civility $civility): string {
return $this->translatableStringHelper->localize($civility->getName());
}
fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName())
)
->setDefault(
'query_builder',
static function (EntityRepository $er): QueryBuilder {
return $er->createQueryBuilder('c')
->where('c.active = true')
->orderBy('c.order');
},
static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c')
->where('c.active = true')
->orderBy('c.order'),
)
->setDefault('placeholder', 'choose civility')
->setDefault('class', Civility::class);

View File

@@ -31,9 +31,7 @@ class PickLocationTypeType extends AbstractType
$resolver
->setDefaults([
'class' => LocationType::class,
'choice_label' => function (LocationType $type) {
return $this->translatableStringHelper->localize($type->getTitle());
},
'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()),
'placeholder' => 'Pick a location type',
'required' => false,
'attr' => ['class' => 'select2'],

View File

@@ -36,11 +36,9 @@ class PickUserLocationType extends AbstractType
->setDefaults([
'class' => Location::class,
'choices' => $this->locationRepository->findByPublicLocations(),
'choice_label' => function (Location $entity) {
return $entity->getName() ?
$entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' :
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle());
},
'choice_label' => fn(Location $entity) => $entity->getName() ?
$entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' :
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()),
'placeholder' => 'Pick a location',
'required' => false,
'attr' => ['class' => 'select2'],

View File

@@ -77,10 +77,8 @@ class PostalCodeType extends AbstractType
$helper = $this->translatableStringHelper;
$resolver
->setDefault('class', PostalCode::class)
->setDefault('choice_label', static function (PostalCode $code) use ($helper) {
return $code->getCode() . ' ' . $code->getName() . ' [' .
$helper->localize($code->getCountry()->getName()) . ']';
})
->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' .
$helper->localize($code->getCountry()->getName()) . ']')
->setDefault('choice_loader', $this->choiceLoader)
->setDefault('placeholder', 'Select a postal code');
}

View File

@@ -66,9 +66,7 @@ class ScopePickerType extends AbstractType
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
$options['center']
),
static function (Scope $s) {
return $s->isActive();
}
static fn(Scope $s) => $s->isActive()
);
if (0 === count($items)) {
@@ -79,9 +77,7 @@ class ScopePickerType extends AbstractType
$builder->add('scope', EntityType::class, [
'class' => Scope::class,
'placeholder' => 'Choose the circle',
'choice_label' => function (Scope $c) {
return $this->translatableStringHelper->localize($c->getName());
},
'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()),
'choices' => $items,
]);
$builder->setDataMapper(new ScopePickerDataMapper());

View File

@@ -79,9 +79,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) {
return $this->userRender->renderString($u, []);
})
->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, []))
->setDefault('scope', null)
->setAllowedTypes('scope', [Scope::class, 'array', 'null'])
->setNormalizer('choices', function (Options $options) {

View File

@@ -77,18 +77,14 @@ class UserType extends AbstractType
'required' => false,
'placeholder' => 'Choose a main scope',
'class' => Scope::class,
'choice_label' => function (Scope $c) {
return $this->translatableStringHelper->localize($c->getName());
},
'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()),
])
->add('userJob', EntityType::class, [
'label' => 'user job',
'required' => false,
'placeholder' => 'choose a job',
'class' => UserJob::class,
'choice_label' => function (UserJob $c) {
return $this->translatableStringHelper->localize($c->getLabel());
},
'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()),
'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('uj');
$qb->where('uj.active = TRUE');
@@ -101,9 +97,7 @@ class UserType extends AbstractType
'required' => false,
'placeholder' => 'choose a location',
'class' => Location::class,
'choice_label' => function (Location $l) {
return $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName();
},
'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(),
'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('l');
$qb->orderBy('l.locationType');

View File

@@ -69,9 +69,7 @@ class WorkflowStepType extends AbstractType
$choices = array_combine(
array_map(
static function (Transition $transition) {
return $transition->getName();
},
static fn(Transition $transition) => $transition->getName(),
$transitions
),
$transitions
@@ -88,14 +86,10 @@ class WorkflowStepType extends AbstractType
'backward' => 'backward',
'neutral' => 'neutral',
],
'choice_label' => function (string $key) use ($inputLabels) {
return $this->translatableStringHelper->localize($inputLabels[$key]);
},
'choice_attr' => static function (string $key) {
return [
$key => $key,
];
},
'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]),
'choice_attr' => static fn(string $key) => [
$key => $key,
],
'mapped' => false,
'expanded' => true,
'data' => 'forward',

View File

@@ -72,7 +72,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
]
)
->setExtras([
'order' => -9999999,
'order' => -9_999_999,
'icon' => 'map-marker',
]);
@@ -84,7 +84,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'route' => 'chill_main_user_absence_index',
])
->setExtras([
'order' => -8888888,
'order' => -8_888_888,
]);
$menu
@@ -116,7 +116,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
['route' => 'change_my_password']
)
->setExtras([
'order' => 99999999998,
'order' => 99_999_999_998,
]);
}
}
@@ -129,7 +129,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
]
)
->setExtras([
'order' => 99999999999,
'order' => 99_999_999_999,
'icon' => 'power-off',
]);
}

View File

@@ -90,9 +90,7 @@ class SearchProvider
public function getByOrder()
{
//sort the array
uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) {
return $a->getOrder() <=> $b->getOrder();
});
uasort($this->searchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder());
return $this->searchServices;
}
@@ -119,9 +117,7 @@ class SearchProvider
public function getHasAdvancedFormSearchServices()
{
//sort the array
uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) {
return $a->getOrder() <=> $b->getOrder();
});
uasort($this->hasAdvancedFormSearchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder());
return $this->hasAdvancedFormSearchServices;
}

View File

@@ -54,9 +54,7 @@ class AddressReferenceBEFromBestAddress
throw new RuntimeException('could not get the release definition', 0, $e);
}
$asset = array_filter($release['assets'], static function (array $item) use ($lang, $list) {
return 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name'];
});
$asset = array_filter($release['assets'], static fn(array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']);
return array_values($asset)[0]['browser_download_url'];
}

View File

@@ -82,9 +82,7 @@ class PostalCodeBEFromBestAddress
throw new RuntimeException('could not get the release definition', 0, $e);
}
$postals = array_filter($release['assets'], static function (array $item) use ($lang) {
return 'postals.' . $lang . '.csv.gz' === $item['name'];
});
$postals = array_filter($release['assets'], static fn(array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']);
return array_values($postals)[0]['browser_download_url'];
}

View File

@@ -39,9 +39,7 @@ class ChillMailer implements MailerInterface
}
$this->chillLogger->info('chill email sent', [
'to' => array_map(static function (Address $address) {
return $address->getAddress();
}, $message->getTo()),
'to' => array_map(static fn(Address $address) => $address->getAddress(), $message->getTo()),
'subject' => $message->getSubject(),
]);

View File

@@ -134,9 +134,7 @@ final class NotificationTest extends KernelTestCase
$this->assertEquals($senderId, $notification->getSender()->getId());
$this->assertCount(count($addressesIds), $notification->getUnreadBy());
$unreadIds = $notification->getUnreadBy()->map(static function (User $u) {
return $u->getId();
});
$unreadIds = $notification->getUnreadBy()->map(static fn(User $u) => $u->getId());
foreach ($addressesIds as $addresseeId) {
$this->assertContains($addresseeId, $unreadIds);

View File

@@ -96,9 +96,7 @@ final class ScopePickerTypeTest extends TypeTestCase
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->will(
static function ($args) {
return $args[0]['fr'];
}
static fn($args) => $args[0]['fr']
);
$type = new ScopePickerType(

View File

@@ -52,9 +52,7 @@ final class ExtractDateFromPatternTest extends TestCase
$this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound());
$dates = array_map(
static function (DateTimeImmutable $d) {
return $d->format('Y-m-d');
},
static fn(DateTimeImmutable $d) => $d->format('Y-m-d'),
$result->getFound()
);

View File

@@ -211,9 +211,7 @@ final class AuthorizationHelperTest extends KernelTestCase
$centerA
);
$usernames = array_map(static function (User $u) {
return $u->getUsername();
}, $users);
$usernames = array_map(static fn(User $u) => $u->getUsername(), $users);
$this->assertContains('center a_social', $usernames);
}

View File

@@ -105,9 +105,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
[
'%users%' => implode(
', ',
$entityWorkflow->getCurrentStep()->getAllDestUser()->map(function (User $u) {
return $this->userRender->renderString($u, []);
})->toArray()
$entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn(User $u) => $this->userRender->renderString($u, []))->toArray()
),
]
));

View File

@@ -109,9 +109,7 @@ class NotificationOnTransition implements EventSubscriberInterface
'dest' => $subscriber,
'place' => $place,
'workflow' => $workflow,
'is_dest' => in_array($subscriber->getId(), array_map(static function (User $u) {
return $u->getId();
}, $entityWorkflow->futureDestUsers), true),
'is_dest' => in_array($subscriber->getId(), array_map(static fn(User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true),
];
$notification = new Notification();

View File

@@ -59,9 +59,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const
$workflows = $this->entityWorkflowManager->getSupportedWorkflows($value);
$matched = array_filter($workflows, static function (WorkflowInterface $workflow) use ($value) {
return $workflow->getName() === $value->getWorkflowName();
});
$matched = array_filter($workflows, static fn(WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName());
if (0 === count($matched)) {
$this->context->buildViolation($constraint->messageWorkflowNotAvailable)