From 75d2d50dd23b5da773ee6e4a1aa2b198ba4c9d8c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 16 Nov 2021 15:25:48 +0100 Subject: [PATCH] fix: SA: Fix "...Variable in isset() is never defined...." rule. SA stands for Static Analysis. --- phpstan-baseline.neon | 5 ----- .../CRUD/Controller/ApiController.php | 14 ++++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e7ec53126..40b6b2425 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -30,11 +30,6 @@ parameters: count: 1 path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php - - - message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php - - message: "#^Variable method call on object\\.$#" count: 2 diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index a2555bf81..3a390a286 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -347,7 +347,6 @@ class ApiController extends AbstractCRUDController * * @param string $action * @param Request $request - * @return type */ protected function indexApiAction($action, Request $request, $_format) { @@ -358,9 +357,7 @@ class ApiController extends AbstractCRUDController return $response; } - if (!isset($entity)) { - $entity = ''; - } + $entity = ''; $response = $this->onPostCheckACL($action, $request, $_format, $entity); if ($response instanceof Response) { @@ -370,8 +367,13 @@ class ApiController extends AbstractCRUDController $totalItems = $this->countEntities($action, $request, $_format); $paginator = $this->getPaginatorFactory()->create($totalItems); - $response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems, - $paginator); + $response = $this->onPreIndexBuildQuery( + $action, + $request, + $_format, + $totalItems, + $paginator + ); if ($response instanceof Response) { return $response;