From d1c94b0e3e3579db7df5c700f064925bdb871eb2 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 6 Mar 2021 19:48:55 +0100 Subject: [PATCH] [GH-4112] Add deprecation for Driver\AbstractException::getErrorCode. --- lib/Doctrine/DBAL/Driver/AbstractException.php | 8 ++++++++ lib/Doctrine/DBAL/Driver/PDOException.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/Doctrine/DBAL/Driver/AbstractException.php b/lib/Doctrine/DBAL/Driver/AbstractException.php index 65a9708ad65..22718783e36 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractException.php +++ b/lib/Doctrine/DBAL/Driver/AbstractException.php @@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\Deprecations\Deprecation; use Exception as BaseException; /** @@ -47,6 +48,13 @@ public function __construct($message, $sqlState = null, $errorCode = null) */ public function getErrorCode() { + /** @psalm-suppress ImpureMethodCall */ + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4112', + 'Driver\AbstractException::getErrorCode() is deprecated, use getSQLState() or getCode() instead.' + ); + return $this->errorCode; } diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php index b2c01eb4430..8c0d05d2ab7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/lib/Doctrine/DBAL/Driver/PDOException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\PDO\Exception; +use Doctrine\Deprecations\Deprecation; /** * @deprecated Use {@link Exception} instead @@ -43,6 +44,13 @@ public function __construct(\PDOException $exception) */ public function getErrorCode() { + /** @psalm-suppress ImpureMethodCall */ + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4112', + 'Driver\AbstractException::getErrorCode() is deprecated, use getSQLState() or getCode() instead.' + ); + return $this->errorCode; }