fix: SA: Fix many critical rules.

SA stands for Static Analysis.
This commit is contained in:
Pol Dellaiera
2021-11-16 17:13:39 +01:00
parent db2010082a
commit 5432242376
19 changed files with 345 additions and 655 deletions

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\PersonBundle\Entity\Person;
@@ -24,6 +26,8 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
private CONST NUMBER_OF_HOUSEHOLD = 10;
private array $personIds;
public function __construct(MembersEditorFactory $editorFactory, EntityManagerInterface $em)
{
$this->editorFactory = $editorFactory;
@@ -149,14 +153,14 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
private function preparePersonIds()
{
// @TODO: Remove this and make this service stateless
$this->personIds = $this->em
->createQuery('SELECT p.id FROM '.Person::class.' p '.
'JOIN p.center c '.
'WHERE c.name = :center '
)
->setParameter('center', 'Center A')
->getScalarResult()
;
->getScalarResult();
\shuffle($this->personIds);
}
@@ -169,9 +173,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
for ($i=0; $i < $nb; $i++) {
$personId = \array_pop($this->personIds)['id'];
$persons[] = $this->em->getRepository(Person::class)
->find($personId)
;
$persons[] = $this->em->getRepository(Person::class)->find($personId);
}
return $persons;