From cc750d743b9008daf28b1088fbc560a4f7cc2dc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 20 Jun 2022 08:12:09 +0200 Subject: [PATCH] Changes: - some methods now need to return bool to be compatible - added some missing type-hints --- tests/Util/Database/ExtendedPDO.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/Util/Database/ExtendedPDO.php b/tests/Util/Database/ExtendedPDO.php index b127e312ca..b36c126d5b 100644 --- a/tests/Util/Database/ExtendedPDO.php +++ b/tests/Util/Database/ExtendedPDO.php @@ -33,7 +33,7 @@ class ExtendedPDO extends PDO /** * @var array Database drivers that support SAVEPOINT * statements. */ - protected static $_supportedDrivers = ["pgsql", "mysql"]; + protected static $_supportedDrivers = ['pgsql', 'mysql']; /** * @var int the current transaction depth @@ -80,9 +80,9 @@ class ExtendedPDO extends PDO /** * Commit current transaction * - * @return bool|void + * @return bool */ - public function commit() + public function commit(): bool { // We don't want to "really" commit something, so skip the most outer hierarchy if ($this->_transactionDepth <= 1 && $this->hasSavepoint()) { @@ -92,28 +92,29 @@ class ExtendedPDO extends PDO $this->_transactionDepth--; - $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}"); + return $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}"); } /** * Rollback current transaction, * * @throws PDOException if there is no transaction started - * @return bool|void + * @return bool Whether rollback was successful */ - public function rollBack() + public function rollback(): bool { $this->_transactionDepth--; - if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) { + if ($this->_transactionDepth <= 0 || !$this->hasSavepoint()) { $this->_transactionDepth = 0; try { - parent::rollBack(); + return parent::rollBack(); } catch (PDOException $e) { // this shouldn't happen, but it does ... } } else { - $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}"); + return $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}"); } + return false; } } -- 2.39.5