DX: fix phpstan errors

This commit is contained in:
2023-02-07 23:49:56 +01:00
parent f57555dab4
commit 8ccce12e54
13 changed files with 21 additions and 201 deletions

View File

@@ -117,7 +117,7 @@ class PersonMove
$from->getId()
);
return $sqls ?? [];
return $sqls;
}
protected function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string

View File

@@ -283,8 +283,7 @@ final class ImportPeopleFromCSVCommand extends Command
$openingDateString = trim($row[array_search('opening_date', $headers, true)]);
$openingDate = $this->processDate($openingDateString, $this->input->getOption('opening_date_format'));
// @TODO: Fix the constructor parameter, $openingDate does not exists.
$person = $openingDate instanceof DateTime ? new Person($openingDate) : new Person();
$person = new Person();
// add the center
$center = $this->getCenter($row, $headers);
@@ -377,6 +376,7 @@ final class ImportPeopleFromCSVCommand extends Command
$address->setPostcode($postalCode);
if (in_array('street1', $headers, true)) {
/** @phpstan-ignore-next-line as this command is deprecated */
$address->setStreetAddress1($street1Value);
}
$address->setValidFrom(new DateTime('today'));
@@ -1024,7 +1024,6 @@ final class ImportPeopleFromCSVCommand extends Command
foreach ($possibleFormats as $format) {
$this->logger->debug("Trying format {$format}", [__METHOD__]);
/** @phpstan-ignore-next-line */
$dateR = strptime($value, $format);
if (is_array($dateR) && '' === $dateR['unparsed']) {

View File

@@ -407,6 +407,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
private function createExpectedPerson($default): Person
{
/** @var Person $person */
$person = $this->loader->loadData([
Person::class => [
'person' => [
@@ -439,10 +440,15 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
break;
case 'countryOfBirth':
$country = $this->countryRepository
->findOneBy(['countryCode' => $value]);
$person->setCountryOfBirth($country);
break;
case 'nationality':
$country = $this->countryRepository
->findOneBy(['countryCode' => $value]);
$person->{'set' . ucfirst($key)}($country);
$person->setNationality($country);
break;
@@ -484,42 +490,6 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
return $this->getReference($ref);
}
/**
* Create a random address.
*
* @return Address
*/
private function getRandomAddress()
{
return (new Address())
->setStreetAddress1($this->faker->streetAddress)
->setStreetAddress2(
mt_rand(0, 9) > 5 ? $this->faker->streetAddress : ''
)
->setPoint(
mt_rand(0, 9) > 5 ? $this->getRandomPoint() : null
)
->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
))
->setValidFrom($this->faker->dateTimeBetween('-5 years'));
}
/**
* Create a random point.
*
* @return Point
*/
private function getRandomPoint()
{
$lonBrussels = 4.35243;
$latBrussels = 50.84676;
$lon = $lonBrussels + 0.01 * mt_rand(-5, 5);
$lat = $latBrussels + 0.01 * mt_rand(-5, 5);
return Point::fromLonLat($lon, $lat);
}
private function getRandomSocialIssue(): SocialIssue
{
if (0 === count($this->cacheSocialIssues)) {

View File

@@ -111,9 +111,9 @@ final class GoalRepository implements ObjectRepository
$orx = $qb->expr()->orX();
$i = 0;
foreach ($actions as $action) {
foreach ($actions as $act) {
$orx->add(":action_{$i} MEMBER OF g.socialActions");
$qb->setParameter("action_{$i}", $action);
$qb->setParameter("action_{$i}", $act);
}
$qb->where($orx);

View File

@@ -146,9 +146,9 @@ final class ResultRepository implements ObjectRepository
$orx = $qb->expr()->orX();
$i = 0;
foreach ($actions as $action) {
foreach ($actions as $act) {
$orx->add(":action_{$i} MEMBER OF r.socialActions");
$qb->setParameter("action_{$i}", $action);
$qb->setParameter("action_{$i}", $act);
}
$qb->where($orx);