DX: apply rector rulesset up to PHP72

This commit is contained in:
2023-03-29 22:32:52 +02:00
parent 64b8ae3df1
commit b9a7530f7a
110 changed files with 194 additions and 229 deletions

View File

@@ -162,7 +162,7 @@ final class PersonController extends AbstractController
$cFGroup = null;
$cFDefaultGroup = $this->em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class)
->findOneByEntity('Chill\\PersonBundle\\Entity\\Person');
->findOneByEntity(\Chill\PersonBundle\Entity\Person::class);
if ($cFDefaultGroup) {
$cFGroup = $cFDefaultGroup->getCustomFieldsGroup();

View File

@@ -125,12 +125,12 @@ class LoadCustomFields extends AbstractFixture implements
// select a set of people and add data
foreach ($personIds as $id) {
// add info on 1 person on 2
if (mt_rand(0, 1) === 1) {
if (random_int(0, 1) === 1) {
/** @var Person $person */
$person = $manager->getRepository(Person::class)->find($id);
$person->setCFData([
'remarques' => $this->createCustomFieldText()
->serialize($faker->text(mt_rand(150, 250)), $this->customFieldText),
->serialize($faker->text(random_int(150, 250)), $this->customFieldText),
'document-d-identite' => $this->createCustomFieldChoice()
->serialize([$choices[array_rand($choices)]], $this->customFieldChoice),
]);

View File

@@ -1006,7 +1006,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
'property' => 'step',
],
'supports' => [
'Chill\PersonBundle\Entity\AccompanyingPeriod',
\Chill\PersonBundle\Entity\AccompanyingPeriod::class,
],
'initial_marking' => 'DRAFT',
'places' => [
@@ -1043,7 +1043,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$container->prependExtensionConfig(
'chill_custom_fields',
['customizables_entities' => [
['class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity'],
['class' => \Chill\PersonBundle\Entity\Person::class, 'name' => 'PersonEntity'],
],
]
);

View File

@@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('cl_chill_person');
$rootNode = $treeBuilder->getRootNode('cl_chill_person');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->canBeDisabled()
@@ -137,7 +137,7 @@ class Configuration implements ConfigurationInterface
private function addFieldNode($key)
{
$tree = new TreeBuilder($key, 'enum');
$node = $tree->getRootNode($key);
$node = $tree->getRootNode();
switch ($key) {
case 'accompanying_period':

View File

@@ -200,7 +200,7 @@ class Household
*/
public function getCurrentAddress(?DateTime $at = null): ?Address
{
$at = null === $at ? new DateTime('today') : $at;
$at = $at ?? new DateTime('today');
$addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) {
return $a->getValidFrom() <= $at && (
@@ -412,7 +412,7 @@ class Household
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = null === $now ? (new DateTimeImmutable('today')) : $now;
$date = $now ?? new DateTimeImmutable('today');
$criteria
->where(
@@ -634,7 +634,7 @@ class Household
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = null === $now ? (new DateTimeImmutable('today')) : $now;
$date = $now ?? new DateTimeImmutable('today');
$criteria
->where($expr->orX(

View File

@@ -142,7 +142,7 @@ class HouseholdMember
public function isCurrent(?DateTimeImmutable $at = null): bool
{
$at = null === $at ? new DateTimeImmutable('now') : $at;
$at = $at ?? new DateTimeImmutable('now');
return $this->getStartDate() < $at && (
null === $this->getEndDate() || $this->getEndDate() > $at

View File

@@ -1087,7 +1087,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = null === $at ? new DateTimeImmutable('today') : $at;
$date = $at ?? new DateTimeImmutable('today');
$datef = $date->format('Y-m-d');
if (

View File

@@ -42,8 +42,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
{
$where = $qb->getDQLPart('where');
$min = null !== $data['min_age'] ? $data['min_age'] : 0;
$max = null !== $data['max_age'] ? $data['max_age'] : 150;
$min = $data['min_age'] ?? 0;
$max = $data['max_age'] ?? 150;
$calc = $this->rollingDateConverter->convert($data['date_calc']);
$minDate = $calc->sub(new DateInterval('P' . $max . 'Y'));

View File

@@ -98,7 +98,7 @@ class AccompanyingPeriodType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'Chill\PersonBundle\Entity\AccompanyingPeriod',
'data_class' => \Chill\PersonBundle\Entity\AccompanyingPeriod::class,
]);
$resolver

View File

@@ -250,7 +250,7 @@ class PersonType extends AbstractType
$resolver->setAllowedTypes(
'cFGroup',
['null', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup']
['null', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class]
);
}

View File

@@ -40,13 +40,13 @@ class Select2MaritalStatusType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$transformer = new ObjectToIdTransformer($this->em, 'Chill\PersonBundle\Entity\MaritalStatus');
$transformer = new ObjectToIdTransformer($this->em, \Chill\PersonBundle\Entity\MaritalStatus::class);
$builder->addModelTransformer($transformer);
}
public function configureOptions(OptionsResolver $resolver)
{
$maritalStatuses = $this->em->getRepository('Chill\PersonBundle\Entity\MaritalStatus')->findAll();
$maritalStatuses = $this->em->getRepository(\Chill\PersonBundle\Entity\MaritalStatus::class)->findAll();
$choices = [];
foreach ($maritalStatuses as $ms) {

View File

@@ -168,7 +168,7 @@ class MembersEditor
$criteria->where(
$expr->andX(
$expr->lt('startDate', $date),
$expr->isNull('endDate', $date)
$expr->isNull('endDate')
)
);

View File

@@ -44,7 +44,7 @@ class ResidentialAddressRepository extends ServiceEntityRepository
public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder
{
$date = null === $at ? new DateTimeImmutable('today') : $at;
$date = $at ?? new DateTimeImmutable('today');
$qb = $this->createQueryBuilder('ra');
$dateFilter = $qb->expr()->andX(

View File

@@ -34,7 +34,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem
public function remove(DateInterval $interval): void
{
$this->logger->debug('[' . __CLASS__ . '] start to remove old periods', [
$this->logger->debug('[' . self::class . '] start to remove old periods', [
'interval' => $interval->format('%d days'),
]);
@@ -96,7 +96,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem
];
});
$this->logger->info('[' . __CLASS__ . '] periods removed', array_merge($results, [
$this->logger->info('[' . self::class . '] periods removed', array_merge($results, [
'interval' => $interval->format('%d days'),
]));
}

View File

@@ -162,7 +162,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase
->setNextMembership($nextMembership);
$notificationPersister = $this->prophesize(NotificationPersisterInterface::class);
$notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled(1);
$notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled();
$eventSubscriber = $this->buildSubscriber(null, $notificationPersister->reveal(), null, null);
$eventSubscriber->resetPeriodLocation($event);

View File

@@ -89,7 +89,7 @@ final class PersonControllerCreateTest extends WebTestCase
$form = $crawler->selectButton('Ajouter la personne')->form();
$this->assertInstanceOf(
'Symfony\Component\DomCrawler\Form',
\Symfony\Component\DomCrawler\Form::class,
$form,
'The page contains a butto '
);

View File

@@ -158,7 +158,7 @@ final class PersonVoterTest extends KernelTestCase
{
$token = $this->prophet->prophesize();
$token
->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
if (null === $permissions) {
$token->getUser()->willReturn(null);

View File

@@ -88,7 +88,7 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
foreach ($expected as $key => $item) {
if ('@ignored' === $item) {
if (0 === $item) {
continue;
}

View File

@@ -187,8 +187,7 @@ final class PersonContextTest extends TestCase
{
$builder = $this->prophesize(FormBuilderInterface::class);
$builder->add('title', TextType::class, Argument::type('array'))
->shouldBeCalled(1);
$builder->add('title', TextType::class, Argument::type('array'))->shouldBeCalled();
if ($withScope) {
$builder->add('scope', ScopePickerType::class, Argument::type('array'))