]> git.mxchange.org Git - friendica.git/commitdiff
Added more type-hints
authorRoland Häder <roland@mxchange.org>
Thu, 16 Jun 2022 18:33:10 +0000 (20:33 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 17 Jun 2022 15:18:31 +0000 (17:18 +0200)
src/Database/DBA.php
src/Database/Database.php

index a0eb1c3eceec382ceab0ffeca03f2ff264dcb6d7..2cafc4e0a6a80e218e045993df5732750d0d0745 100644 (file)
@@ -512,7 +512,7 @@ class DBA
         * $count = DBA::count($table, $condition);
         * @throws \Exception
         */
-       public static function count($table, array $condition = [], array $params = [])
+       public static function count($table, array $condition = [], array $params = []): int
        {
                return DI::dba()->count($table, $condition, $params);
        }
@@ -771,7 +771,7 @@ class DBA
         *
         * @return array Data array
         */
-       public static function toArray($stmt, $do_close = true, int $count = 0)
+       public static function toArray($stmt, $do_close = true, int $count = 0): array
        {
                return DI::dba()->toArray($stmt, $do_close, $count);
        }
@@ -783,7 +783,7 @@ class DBA
         * @param array  $fields
         * @return array casted fields
         */
-       public static function castFields(string $table, array $fields)
+       public static function castFields(string $table, array $fields): array
        {
                return DI::dba()->castFields($table, $fields);
        }
@@ -793,7 +793,7 @@ class DBA
         *
         * @return string Error number (0 if no error)
         */
-       public static function errorNo()
+       public static function errorNo(): int
        {
                return DI::dba()->errorNo();
        }
@@ -803,7 +803,7 @@ class DBA
         *
         * @return string Error message ('' if no error)
         */
-       public static function errorMessage()
+       public static function errorMessage(): string
        {
                return DI::dba()->errorMessage();
        }
@@ -814,7 +814,7 @@ class DBA
         * @param object $stmt statement object
         * @return boolean was the close successful?
         */
-       public static function close($stmt)
+       public static function close($stmt): bool
        {
                return DI::dba()->close($stmt);
        }
@@ -827,7 +827,7 @@ class DBA
         *      'amount' => Number of concurrent database processes
         * @throws \Exception
         */
-       public static function processlist()
+       public static function processlist(): array
        {
                return DI::dba()->processlist();
        }
index 671425f9d188c8d19a42f0544b177db7aa9a98d6..7edbdf2a2c695dbecc9f7b87ab6ddf0e6f70940d 100644 (file)
@@ -541,7 +541,7 @@ class Database
                                        if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
                                                $errorInfo     = $this->connection->errorInfo();
                                                $this->error   = $errorInfo[2];
-                                               $this->errorno = $errorInfo[1];
+                                               $this->errorno = (int) $errorInfo[1];
                                                $retval        = false;
                                                $is_error      = true;
                                                break;
@@ -554,7 +554,7 @@ class Database
                                if (!$stmt = $this->connection->prepare($sql)) {
                                        $errorInfo     = $this->connection->errorInfo();
                                        $this->error   = $errorInfo[2];
-                                       $this->errorno = $errorInfo[1];
+                                       $this->errorno = (int) $errorInfo[1];
                                        $retval        = false;
                                        $is_error      = true;
                                        break;
@@ -574,7 +574,7 @@ class Database
                                if (!$stmt->execute()) {
                                        $errorInfo     = $stmt->errorInfo();
                                        $this->error   = $errorInfo[2];
-                                       $this->errorno = $errorInfo[1];
+                                       $this->errorno = (int) $errorInfo[1];
                                        $retval        = false;
                                        $is_error      = true;
                                } else {
@@ -709,7 +709,7 @@ class Database
                        }
 
                        $this->error   = $error;
-                       $this->errorno = $errorno;
+                       $this->errorno = (int) $errorno;
                }
 
                $this->profiler->stopRecording();
@@ -1541,7 +1541,7 @@ class Database
         *
         * @return array Data array
         */
-       public function toArray($stmt, $do_close = true, int $count = 0)
+       public function toArray($stmt, bool $do_close = true, int $count = 0): array
        {
                if (is_bool($stmt)) {
                        return [];
@@ -1632,7 +1632,7 @@ class Database
         *
         * @return string Error number (0 if no error)
         */
-       public function errorNo()
+       public function errorNo(): int
        {
                return $this->errorno;
        }
@@ -1654,7 +1654,7 @@ class Database
         *
         * @return boolean was the close successful?
         */
-       public function close($stmt)
+       public function close($stmt): bool
        {
 
                $this->profiler->startRecording('database');
@@ -1696,7 +1696,7 @@ class Database
         *      'amount' => Number of concurrent database processes
         * @throws \Exception
         */
-       public function processlist()
+       public function processlist(): array
        {
                $ret  = $this->p("SHOW PROCESSLIST");
                $data = $this->toArray($ret);