diff --git a/phpstan.neon b/phpstan.neon index d970ef6b..8e62eb53 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,14 +2,6 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon parameters: - ignoreErrors: - # A workaround for Doctrine not specifying an UniqueConstraintViolationException being thrown - # See https://github.com/doctrine/orm/issues/7780 - # This rule might be unneccessary in the future with a fixe discussed in - # https://github.com/phpstan/phpstan-doctrine/issues/295 - - message: /Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException is never thrown in the try block/ - path: src/DataAccess/DoctrinePaymentRepository.php - count: 1 excludePaths: analyse: diff --git a/src/DataAccess/DoctrinePaymentRepository.php b/src/DataAccess/DoctrinePaymentRepository.php index 12df7370..494201d2 100644 --- a/src/DataAccess/DoctrinePaymentRepository.php +++ b/src/DataAccess/DoctrinePaymentRepository.php @@ -17,7 +17,9 @@ public function storePayment( Payment $payment ): void { $this->entityManager->persist( $payment ); try { $this->entityManager->flush(); - } catch ( UniqueConstraintViolationException $ex ) { + // TODO Remove allowing \RuntimeException when the discussion on https://github.com/doctrine/orm/pull/10785 + // has been resolved. Hopefully, they'll re-introduce UniqueConstraintViolationException in a patch release + } catch ( UniqueConstraintViolationException|\RuntimeException $ex ) { throw new PaymentOverrideException( $ex->getMessage(), $ex->getCode(), $ex ); } }