diff --git a/app/controllers/Update.php b/app/controllers/Update.php index 0bd1911..741ebc0 100644 --- a/app/controllers/Update.php +++ b/app/controllers/Update.php @@ -25,9 +25,9 @@ final class Update /** * Updates the system to the given release zip * @param string path to the release zip file - * @return true|int true on success, an error code otherwise + * @return int|bool true on success, an error code otherwise */ - public function run(string $zip): true|int + public function run(string $zip): int|bool { $temp_dir = sys_get_temp_dir(); $zip_dir = tempnam($temp_dir, 'aurora-update'); @@ -59,11 +59,11 @@ public function run(string $zip): true|int /** * Returns an array with data about the latest release compatible with the current version (same major version) - * @return array|false|int the array with data about the latest release, + * @return array|bool|int the array with data about the latest release, * false if there are no new releases compatible with the current version * or an error code in case of errors */ - public function getLatestRelease(): array|false|int + public function getLatestRelease(): array|bool|int { $releases = @file_get_contents('https://api.github.com/repos/usbac/aurora/releases', false, self::getStreamContext()); diff --git a/app/controllers/modules/Link.php b/app/controllers/modules/Link.php index a41a7c6..8f9700a 100755 --- a/app/controllers/modules/Link.php +++ b/app/controllers/modules/Link.php @@ -17,7 +17,7 @@ public function getHeaderLinks(): array return $this->getPage(null, null, 'status', 'order'); } - public function add(array $data): string|false + public function add(array $data): string|bool { return $this->db->insert($this->table, $this->getBaseData($data)); } diff --git a/app/controllers/modules/Page.php b/app/controllers/modules/Page.php index bd5f10c..859ea33 100755 --- a/app/controllers/modules/Page.php +++ b/app/controllers/modules/Page.php @@ -16,7 +16,7 @@ final class Page extends \Aurora\App\ModuleBase 'views' => 'views DESC, pages.title ASC', ]; - public function add(array $data): string|false + public function add(array $data): string|bool { return $this->db->insert($this->table, $this->getBaseData($data)); } diff --git a/app/controllers/modules/Post.php b/app/controllers/modules/Post.php index f047385..adbe223 100755 --- a/app/controllers/modules/Post.php +++ b/app/controllers/modules/Post.php @@ -30,7 +30,7 @@ protected function getRowData($data): mixed return $data; } - public function add(array $data): string|false + public function add(array $data): string|bool { try { $this->db->connection->beginTransaction(); diff --git a/app/controllers/modules/Tag.php b/app/controllers/modules/Tag.php index 567b111..242d94a 100755 --- a/app/controllers/modules/Tag.php +++ b/app/controllers/modules/Tag.php @@ -14,7 +14,7 @@ final class Tag extends \Aurora\App\ModuleBase 'posts' => 'COUNT(post_id) DESC, tags.name ASC', ]; - public function add(array $data): string|false + public function add(array $data): string|bool { return $this->db->insert($this->table, $this->getBaseData($data)); } diff --git a/app/controllers/modules/User.php b/app/controllers/modules/User.php index 0e3e00b..880c426 100755 --- a/app/controllers/modules/User.php +++ b/app/controllers/modules/User.php @@ -38,7 +38,7 @@ public function save(int $id, array $data): int|false return $res ? $id : false; } - public function add(array $data): string|false + public function add(array $data): string|bool { $time = time(); return $this->db->insert($this->table, [ diff --git a/bootstrap/index.php b/bootstrap/index.php index b5c8b20..bec9a75 100644 --- a/bootstrap/index.php +++ b/bootstrap/index.php @@ -16,7 +16,7 @@ function t(?string $key = null, bool $escape = true) } if (!function_exists('js')) { - function js(mixed $val): string|false + function js(mixed $val): string|bool { return json_encode($val); } diff --git a/system/DB.php b/system/DB.php index 9606fae..b6086e3 100755 --- a/system/DB.php +++ b/system/DB.php @@ -47,9 +47,9 @@ public function query(string $sql, ...$args): \PDOStatement|false * Inserts a row into the specified table * @param string $table the table * @param array $data the row data - * @return string|false the id of the inserted row on success, false otherwise + * @return string|bool the id of the inserted row on success, false otherwise */ - public function insert(string $table, array $data): string|false + public function insert(string $table, array $data): string|bool { return $this->intoOperation('INSERT', $table, $data); } @@ -58,9 +58,9 @@ public function insert(string $table, array $data): string|false * Replaces a row into the specified table * @param string $table the table * @param array $data the row data - * @return string|false the id of the replaced row on success, false otherwise + * @return string|bool the id of the replaced row on success, false otherwise */ - public function replace(string $table, array $data): string|false + public function replace(string $table, array $data): string|bool { return $this->intoOperation('REPLACE', $table, $data); } @@ -135,9 +135,9 @@ public function escape(string $str): string * @param string $statement the statement (e.g., INSERT, REPLACE) * @param string $table the table * @param array $data the row data - * @return string|false the id of the row on success, false otherwise + * @return string|bool the id of the row on success, false otherwise */ - private function intoOperation(string $statement, string $table, array $data = []): string|false + private function intoOperation(string $statement, string $table, array $data = []): string|bool { $keys = array_map(fn($key) => "`$key`", array_keys($data));