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

@@ -344,7 +344,7 @@ class ReportController extends AbstractController
}
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findByEntity('Chill\ReportBundle\Entity\Report');
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
return $this->redirect(
@@ -403,7 +403,7 @@ class ReportController extends AbstractController
$em = $this->getDoctrine()->getManager();
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findByEntity('Chill\ReportBundle\Entity\Report');
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
return $this->redirect(

View File

@@ -68,15 +68,15 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
];
for ($i = 0; 25 >= $i; ++$i) {
$cFType = $cFTypes[mt_rand(0, count($cFTypes) - 1)];
$cFType = $cFTypes[random_int(0, count($cFTypes) - 1)];
$customField = (new CustomField())
->setSlug("cf_report_{$i}")
->setType($cFType['type'])
->setOptions($cFType['options'])
->setName(['fr' => "CustomField {$i}"])
->setOrdering(mt_rand(0, 1000) / 1000)
->setCustomFieldsGroup($this->getReference('cf_group_report_' . (mt_rand(0, 3))));
->setOrdering(random_int(0, 1000) / 1000)
->setCustomFieldsGroup($this->getReference('cf_group_report_' . (random_int(0, 3))));
$manager->persist($customField);
}

View File

@@ -66,7 +66,7 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
$cFGroup = (new CustomFieldsGroup())
->setName($name)
->setEntity('Chill\ReportBundle\Entity\Report')
->setEntity(\Chill\ReportBundle\Entity\Report::class)
->setOptions($options);
$manager->persist($cFGroup);

View File

@@ -88,7 +88,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
$report = (new Report())
->setPerson($person)
->setCFGroup(
mt_rand(0, 10) > 5 ?
random_int(0, 10) > 5 ?
$this->getReference('cf_group_report_logement') :
$this->getReference('cf_group_report_education')
)
@@ -111,7 +111,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
//set date. 30% of the dates are 2015-05-01
$expectedDate = new DateTime('2015-01-05');
if (mt_rand(0, 100) < 30) {
if (random_int(0, 100) < 30) {
$report->setDate($expectedDate);
} else {
$report->setDate($this->faker->dateTimeBetween('-1 year', 'now')
@@ -155,7 +155,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
$selectedPeople = [];
foreach ($people as $person) {
if (mt_rand(0, 100) < $percentage) {
if (random_int(0, 100) < $percentage) {
$selectedPeople[] = $person;
}
}
@@ -183,7 +183,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
$picked = [];
if ($multiple) {
$numberSelected = mt_rand(1, count($choices) - 1);
$numberSelected = random_int(1, count($choices) - 1);
for ($i = 0; $i < $numberSelected; ++$i) {
$picked[] = $this->pickChoice($choices);

View File

@@ -41,7 +41,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac
'chill_custom_fields',
['customizables_entities' => [
[
'class' => 'Chill\ReportBundle\Entity\Report',
'class' => \Chill\ReportBundle\Entity\Report::class,
'name' => 'ReportEntity',
'options' => [
'summary_fields' => [

View File

@@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_report');
$rootNode = $treeBuilder->getRootNode('chill_report');
$rootNode = $treeBuilder->getRootNode();
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for

View File

@@ -88,14 +88,14 @@ class ReportType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'Chill\ReportBundle\Entity\Report',
'data_class' => \Chill\ReportBundle\Entity\Report::class,
]);
$resolver->setRequired([
'cFGroup',
]);
$resolver->setAllowedTypes('cFGroup', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
$resolver->setAllowedTypes('cFGroup', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class);
$this->appendScopeChoicesOptions($resolver);
}

View File

@@ -167,7 +167,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
->orderBy('r.date', 'desc');
$reportQuery = $qb->getQuery();
$reportQuery->setFetchMode('Chill\\ReportBundle\\Entity\\Report', 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER);
$reportQuery->setFetchMode(\Chill\ReportBundle\Entity\Report::class, 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER);
return $reportQuery->getResult();
}

View File

@@ -64,7 +64,7 @@ final class ReportControllerNextTest extends WebTestCase
$customFieldsGroups = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']);
->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]);
//filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups,

View File

@@ -82,7 +82,7 @@ final class ReportControllerTest extends WebTestCase
$customFieldsGroups = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']);
->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]);
//filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups,
@@ -132,7 +132,7 @@ final class ReportControllerTest extends WebTestCase
$form = $crawlerAddAReportPage->selectButton('Créer un nouveau rapport')->form();
$this->assertInstanceOf(
'Symfony\Component\DomCrawler\Form',
\Symfony\Component\DomCrawler\Form::class,
$form,
'I can see a form with a button "add a new report" '
);
@@ -251,7 +251,7 @@ final class ReportControllerTest extends WebTestCase
$link = $crawlerPersonPage->selectLink("AJOUT D'UN RAPPORT")->link();
$this->assertInstanceOf(
'Symfony\Component\DomCrawler\Link',
\Symfony\Component\DomCrawler\Link::class,
$link,
'There is a "add a report" link in menu'
);
@@ -278,7 +278,7 @@ final class ReportControllerTest extends WebTestCase
->form();
$this->assertInstanceOf(
'Symfony\Component\DomCrawler\Form',
\Symfony\Component\DomCrawler\Form::class,
$addForm,
'I have a report form'
);

View File

@@ -32,7 +32,7 @@ final class ChillReportExtensionTest extends KernelTestCase
$reportFounded = false;
foreach ($customizablesEntities as $customizablesEntity) {
if ('Chill\ReportBundle\Entity\Report' === $customizablesEntity['class']) {
if (\Chill\ReportBundle\Entity\Report::class === $customizablesEntity['class']) {
$reportFounded = true;
}
}

View File

@@ -167,7 +167,7 @@ final class ReportVoterTest 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 === $user) {
$token->getUser()->willReturn(null);

View File

@@ -191,6 +191,6 @@ final class TimelineProviderTest extends WebTestCase
}
}
return $groups[mt_rand(0, count($groups) - 1)];
return $groups[random_int(0, count($groups) - 1)];
}
}