Return types

This commit is contained in:
2024-07-22 02:36:28 +02:00
parent af588ab174
commit 2168e37413
12 changed files with 35 additions and 46 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ class Database extends PDO
{
private static array $instances = [];
protected function __construct($dsn, $username = null, $password = null, array $options = null)
protected function __construct(string $dsn, string $username = null, string $password = null, array $options = null)
{
parent::__construct($dsn, $username, $password, $options);
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Khofmann\GUID;
class GUID
{
public static function v4($data = null)
public static function v4($data = null): string
{
// Generate 16 bytes (128 bits) of random data or use the data passed into the function.
$data = $data ?? random_bytes(16);
+4 -6
View File
@@ -6,24 +6,22 @@ use Khofmann\Request\Request;
class Input
{
public static function post($index, $defaultValue = null)
public static function post(string $index, $defaultValue = null)
{
return Request::request()->getInputHandler()->post($index, $defaultValue);
}
public static function patch($index, $defaultValue = null)
public static function patch(string $index, $defaultValue = null)
{
return Request::request()->getInputHandler()->post($index, $defaultValue);
}
public static function get($index, $defaultValue = null)
public static function get(string $index, $defaultValue = null)
{
return Request::request()->getInputHandler()->get($index, $defaultValue);
}
public static function file($index, $defaultValue = null)
public static function file(string $index, $defaultValue = null)
{
return Request::request()->getInputHandler()->file($index, $defaultValue);
}
+7 -3
View File
@@ -155,7 +155,7 @@ class User implements JsonSerializable
}
}
public static function create(string $username, string $email, string $password)
public static function create(string $username, string $email, string $password): bool
{
$db = Database::getInstance();
$guid = GUID::v4();
@@ -186,6 +186,10 @@ class User implements JsonSerializable
throw $err;
}
}
public static function confirm(string $confirmCode): bool
{
}
/*
* Members
*/
@@ -198,7 +202,7 @@ class User implements JsonSerializable
return $stmt->execute();
}
public function update(?string $username, ?string $password, $image = null)
public function update(?string $username, ?string $password, $image = null): bool
{
$db = Database::getInstance();
@@ -233,7 +237,7 @@ class User implements JsonSerializable
return true;
}
public function delete()
public function delete(): bool
{
$db = Database::getInstance();
$stmt = $db->prepare("DELETE FROM egb_benutzer WHERE id = :ID");
+1 -1
View File
@@ -12,7 +12,7 @@ class Request
return SimpleRouter::request();
}
public static function header($name, $defaultValue = null, $tryParse = true)
public static function header(string $name, $defaultValue = null, bool $tryParse = true): ?string
{
return request()->getHeader($name, $defaultValue, $tryParse);
}
+2 -2
View File
@@ -12,13 +12,13 @@ class Response
return SimpleRouter::response();
}
public static function json($value, int $options = 0, int $dept = 512)
public static function json($value, int $options = 0, int $dept = 512): void
{
if (is_bool($value)) {
Response::response()->header('Content-Type: application/json; charset=utf-8');
echo json_encode($value, $options, $dept);
exit(0);
}
return SimpleRouter::response()->json($value, $options, $dept);
SimpleRouter::response()->json($value, $options, $dept);
}
}