From c42f62de4c9abf2b1dafff6c80142c26b426ccb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Jan 2022 00:32:47 +0100 Subject: [PATCH] fix phpstan errors: undefined variable or type invalid --- phpstan-baseline.neon | 5 ---- phpstan-critical.neon | 30 ------------------- phpstan-types.neon | 5 ---- .../AccompanyingPeriodWorkRepository.php | 21 ++----------- .../Controller/SingleTaskController.php | 2 +- 5 files changed, 4 insertions(+), 59 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d996ff3b8..20970a799 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -80,11 +80,6 @@ parameters: count: 1 path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php - - - message: "#^Foreach overwrites \\$action with its value variable\\.$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - message: "#^Foreach overwrites \\$action with its value variable\\.$#" count: 1 diff --git a/phpstan-critical.neon b/phpstan-critical.neon index b214654bf..632356aa6 100644 --- a/phpstan-critical.neon +++ b/phpstan-critical.neon @@ -30,36 +30,6 @@ parameters: count: 2 path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php - - - message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - - - message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - - - message: "#^Undefined variable\\: \\$action$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - - - message: "#^Undefined variable\\: \\$limit$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - - - message: "#^Undefined variable\\: \\$offset$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - - - message: "#^Undefined variable\\: \\$orderBy$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - message: "#^Variable variables are not allowed\\.$#" count: 4 diff --git a/phpstan-types.neon b/phpstan-types.neon index 949ff774a..2cc55255a 100644 --- a/phpstan-types.neon +++ b/phpstan-types.neon @@ -400,11 +400,6 @@ parameters: count: 1 path: src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php - - - message: "#^Method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid return type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\QueryBuilder\\.$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 3 diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 1b56b6cdf..70e972aa5 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; @@ -97,22 +98,6 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository return AccompanyingPeriodWork::class; } - public function toDelete() - { - $qb = $this->buildQueryBySocialActionWithDescendants($action); - $qb->select('g'); - - foreach ($orderBy as $sort => $order) { - $qb->addOrderBy('g.' . $sort, $order); - } - - return $qb - ->setMaxResults($limit) - ->setFirstResult($offset) - ->getQuery() - ->getResult(); - } - private function buildQueryBySocialActionWithDescendants(SocialAction $action): QueryBuilder { $actions = $action->getDescendantsWithThis(); @@ -122,9 +107,9 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository $orx = $qb->expr()->orX(); $i = 0; - foreach ($actions as $action) { + foreach ($actions as $a) { $orx->add(":action_{$i} MEMBER OF g.socialActions"); - $qb->setParameter("action_{$i}", $action); + $qb->setParameter("action_{$i}", $a); } $qb->where($orx); diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index bac4c1a2a..61ca37ba0 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -486,7 +486,7 @@ final class SingleTaskController extends AbstractController ); default: - throw new BadRequestException("format not supported: {$format}"); + throw new BadRequestException("format not supported: {$_format}"); } }