diff --git a/.php_cs.dist.php b/.php_cs.dist.php index e9c6bdb36..239bd3eec 100644 --- a/.php_cs.dist.php +++ b/.php_cs.dist.php @@ -62,7 +62,7 @@ $riskyRules = [ 'php_unit_expectation' => false, 'php_unit_mock' => false, 'php_unit_namespaced' => false, - 'random_api_migration' => false, + // 'random_api_migration' => false, // 'static_lambda' => false, 'php_unit_construct' => false, // 'psr_autoloading' => false, diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index 0da266251..2683b0abf 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -48,7 +48,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface ->findAll(); foreach ($persons as $person) { - $activityNbr = rand(0, 3); + $activityNbr = mt_rand(0, 3); for ($i = 0; $i < $activityNbr; ++$i) { $activity = $this->newRandomActivity($person); @@ -73,7 +73,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface // ->setAttendee($this->faker->boolean()) - for ($i = 0; rand(0, 4) > $i; ++$i) { + for ($i = 0; mt_rand(0, 4) > $i; ++$i) { $reason = $this->getRandomActivityReason(); if (null !== $reason) { diff --git a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php index 8d1ba01ba..798b5367b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php +++ b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php @@ -102,7 +102,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = rand(10, 50); + $expected_nb_children = mt_rand(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $companyName = $this->fakerFr->company; @@ -142,7 +142,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = rand(10, 50); + $expected_nb_children = mt_rand(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $manager->persist($this->createChildOption($parent, [ diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php index b3ec7f890..f27d0d4b0 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php @@ -37,7 +37,7 @@ class ChoicesListType extends AbstractType $formData = $form->getData(); if (null === $formData['slug']) { - $slug = uniqid(rand(), true); + $slug = uniqid(mt_rand(), true); $data['slug'] = $slug; $event->setData($data); diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index dd9d8e635..844b7db67 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -78,7 +78,7 @@ class DocGeneratorTemplateController extends AbstractController $fileContent = fopen($tmpfname2, 'r'); // the generated file content - $genDocName = 'doc_' . sprintf('%010d', rand()) . '.docx'; + $genDocName = 'doc_' . sprintf('%010d', mt_rand()) . '.docx'; $getUrlGen = $tempUrlGenerator->generate( 'PUT', diff --git a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php index 2496f04fc..749de649c 100644 --- a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php +++ b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php @@ -40,7 +40,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa for ($i = 0; $i < $expectedNumber; ++$i) { $event = (new Event()) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) - ->setName($this->faker->words(rand(2, 4), true)) + ->setName($this->faker->words(mt_rand(2, 4), true)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setCenter($center) ->setCircle( @@ -72,7 +72,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa /** @var \Chill\PersonBundle\Entity\Person $person */ foreach ($people as $person) { - $nb = rand(0, 3); + $nb = mt_rand(0, 3); for ($i = 0; $i < $nb; ++$i) { $event = $events[array_rand($events)]; diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 51cc89a51..97f9eda79 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -402,7 +402,7 @@ class ExportController extends AbstractController 'alias' => $alias, ]; unset($parameters['_token']); - $key = md5(uniqid(rand(), false)); + $key = md5(uniqid(mt_rand(), false)); $this->redis->setEx($key, 3600, serialize($parameters)); diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php index cea5a7e0e..9495ec8bf 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php @@ -67,7 +67,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt $ar->setRefId($this->faker->numerify('ref-id-######')); $ar->setStreet($this->faker->streetName); - $ar->setStreetNumber(rand(0, 199)); + $ar->setStreetNumber(mt_rand(0, 199)); $ar->setPoint($this->getRandomPoint()); $ar->setPostcode($this->getReference( LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] @@ -87,8 +87,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt { $lonBrussels = 4.35243; $latBrussels = 50.84676; - $lon = $lonBrussels + 0.01 * rand(-5, 5); - $lat = $latBrussels + 0.01 * rand(-5, 5); + $lon = $lonBrussels + 0.01 * mt_rand(-5, 5); + $lat = $latBrussels + 0.01 * mt_rand(-5, 5); return Point::fromLonLat($lon, $lat); } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index ac1f5eeff..28c829b0f 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -121,12 +121,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 (rand(0, 1) === 1) { + if (mt_rand(0, 1) === 1) { /** @var Person $person */ $person = $manager->getRepository(Person::class)->find($id); $person->setCFData([ 'remarques' => $this->createCustomFieldText() - ->serialize($faker->text(rand(150, 250)), $this->customFieldText), + ->serialize($faker->text(mt_rand(150, 250)), $this->customFieldText), 'document-d-identite' => $this->createCustomFieldChoice() ->serialize([$choices[array_rand($choices)]], $this->customFieldChoice), ]); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index 38d8d05de..441ca9170 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -491,10 +491,10 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con return (new Address()) ->setStreetAddress1($this->faker->streetAddress) ->setStreetAddress2( - rand(0, 9) > 5 ? $this->faker->streetAddress : '' + mt_rand(0, 9) > 5 ? $this->faker->streetAddress : '' ) ->setPoint( - rand(0, 9) > 5 ? $this->getRandomPoint() : null + mt_rand(0, 9) > 5 ? $this->getRandomPoint() : null ) ->setPostcode($this->getReference( LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] @@ -511,8 +511,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con { $lonBrussels = 4.35243; $latBrussels = 50.84676; - $lon = $lonBrussels + 0.01 * rand(-5, 5); - $lat = $latBrussels + 0.01 * rand(-5, 5); + $lon = $lonBrussels + 0.01 * mt_rand(-5, 5); + $lat = $latBrussels + 0.01 * mt_rand(-5, 5); return Point::fromLonLat($lon, $lat); } diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php index ae709aacf..5bf496e50 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php @@ -65,15 +65,15 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface ]; for ($i = 0; 25 >= $i; ++$i) { - $cFType = $cFTypes[rand(0, count($cFTypes) - 1)]; + $cFType = $cFTypes[mt_rand(0, count($cFTypes) - 1)]; $customField = (new CustomField()) ->setSlug("cf_report_{$i}") ->setType($cFType['type']) ->setOptions($cFType['options']) ->setName(['fr' => "CustomField {$i}"]) - ->setOrdering(rand(0, 1000) / 1000) - ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (rand(0, 3)))); + ->setOrdering(mt_rand(0, 1000) / 1000) + ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (mt_rand(0, 3)))); $manager->persist($customField); } diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 48b81cc4f..cd4cda368 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -84,7 +84,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co $report = (new Report()) ->setPerson($person) ->setCFGroup( - rand(0, 10) > 5 ? + mt_rand(0, 10) > 5 ? $this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_education') ) @@ -107,7 +107,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co //set date. 30% of the dates are 2015-05-01 $expectedDate = new DateTime('2015-01-05'); - if (rand(0, 100) < 30) { + if (mt_rand(0, 100) < 30) { $report->setDate($expectedDate); } else { $report->setDate($this->faker->dateTimeBetween('-1 year', 'now') @@ -151,7 +151,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co $selectedPeople = []; foreach ($people as $person) { - if (rand(0, 100) < $percentage) { + if (mt_rand(0, 100) < $percentage) { $selectedPeople[] = $person; } } @@ -179,7 +179,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co $picked = []; if ($multiple) { - $numberSelected = rand(1, count($choices) - 1); + $numberSelected = mt_rand(1, count($choices) - 1); for ($i = 0; $i < $numberSelected; ++$i) { $picked[] = $this->pickChoice($choices); diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index af1d234c7..92842aaed 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -187,6 +187,6 @@ class TimelineProviderTest extends WebTestCase } } - return $groups[rand(0, count($groups) - 1)]; + return $groups[mt_rand(0, count($groups) - 1)]; } }