From 688447b7ec0d63c764d1d235cd23d0a7f641de09 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Mon, 11 Mar 2024 11:45:55 +0100 Subject: [PATCH] Simplify exception logical condition When rendering the custom exception page, we test if the MissingRequiredAttributeException. But it also had to be a HTTP exception. That was never the case (also before #313). By removing the first part of the statement, the error message is displayed correctly once again. --- ci/qa/phpstan-baseline.php | 30 ------------------- .../Controller/ExceptionController.php | 3 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/ci/qa/phpstan-baseline.php b/ci/qa/phpstan-baseline.php index 9d4c920a3..88196b8ee 100644 --- a/ci/qa/phpstan-baseline.php +++ b/ci/qa/phpstan-baseline.php @@ -301,41 +301,11 @@ 'count' => 1, 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Instanceof between Symfony\\\\Component\\\\HttpKernel\\\\Exception\\\\HttpException and Surfnet\\\\StepupSelfService\\\\SelfServiceBundle\\\\Exception\\\\MissingRequiredAttributeException will always evaluate to false\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Surfnet\\\\StepupSelfService\\\\SelfServiceBundle\\\\Controller\\\\ExceptionController\\:\\:getPageTitleAndDescription\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Result of && is always false\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Undefined variable\\: \\$description$#', - 'count' => 1, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Undefined variable\\: \\$title$#', - 'count' => 1, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Variable \\$description in isset\\(\\) is never defined\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Variable \\$title in isset\\(\\) is never defined\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot call method getIdentity\\(\\) on Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null\\.$#', 'count' => 2, diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php index 30ae4070b..2d2ecdda2 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php @@ -28,7 +28,6 @@ use Throwable; use Surfnet\StepupBundle\Controller\ExceptionController as BaseExceptionController; use Surfnet\StepupSelfService\SelfServiceBundle\Exception\MissingRequiredAttributeException; -use Symfony\Component\HttpKernel\Exception\HttpException; final class ExceptionController extends BaseExceptionController { @@ -39,7 +38,7 @@ protected function getPageTitleAndDescription(Throwable $exception): array { $translator = $this->getTranslator(); - if ($exception instanceof HttpException && $exception instanceof MissingRequiredAttributeException) { + if ($exception instanceof MissingRequiredAttributeException) { $title = $translator->trans('stepup.error.missing_required_attribute.title'); $description = $exception->getMessage(); }