Skip to content

Commit

Permalink
Update return type of several functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Usbac committed Jan 28, 2024
1 parent 8add7d7 commit 050bcde
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/controllers/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/modules/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/modules/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/modules/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/modules/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/modules/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions system/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 050bcde

Please sign in to comment.