]> git.mxchange.org Git - friendica.git/commitdiff
Changes:
authorRoland Häder <roland@mxchange.org>
Mon, 20 Jun 2022 06:12:09 +0000 (08:12 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 20 Jun 2022 06:12:54 +0000 (08:12 +0200)
- some methods now need to return bool to be compatible
- added some missing type-hints

tests/Util/Database/ExtendedPDO.php

index b127e312cacb848068444e80fa33d7645c0b8394..b36c126d5b90d8d1b58faa1674006588c75f139e 100644 (file)
@@ -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;
        }
 }