diff --git a/app/Http/Controllers/Auth/EmailVerificationController.php b/app/Http/Controllers/Auth/EmailVerificationController.php index 02cd711..44a34df 100644 --- a/app/Http/Controllers/Auth/EmailVerificationController.php +++ b/app/Http/Controllers/Auth/EmailVerificationController.php @@ -47,11 +47,11 @@ public function notify(Request $request, Response $response): void } Alert::default(__('email_verification_link_sent'))->success(); - $response->url('login')->send(302); + $response->url('login')->send(); } Alert::default(__('email_verification_link_not_sent'))->error(); - $response->url('signup')->send(302); + $response->url('signup')->send(); } public function verify(Request $request, Response $response, UpdateAction $updateAction): void @@ -82,6 +82,6 @@ public function verify(Request $request, Response $response, UpdateAction $updat Mail::send(new WelcomeMail($user->email, $user->name)); Alert::default(__('email_verified'))->success(); - $response->url('login')->send(400); + $response->url('login')->send(); } } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index ddd0c7b..762aad0 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -47,11 +47,11 @@ public function notify(Request $request, Response $response): void } Alert::default(__('password_reset_link_sent'))->success(); - $response->back()->send(302); + $response->back()->send(); } Alert::default(__('password_reset_link_not_sent'))->error(); - $response->back()->send(302); + $response->back()->send(); } public function reset(Request $request, Response $response): void @@ -71,7 +71,7 @@ public function reset(Request $request, Response $response): void } $token->delete(); - $response->url("/password/new?email={$request->email}")->send(302); + $response->url("/password/new?email={$request->email}")->send(); } public function update(Request $request, Response $response, LoginValidator $loginValidator, UpdateAction $updateAction): void @@ -81,10 +81,10 @@ public function update(Request $request, Response $response, LoginValidator $log if (!$user) { Alert::default(__('password_not_reset'))->error(); - $response->back()->send(302); + $response->back()->send(); } Alert::default(__('password_reset'))->success(); - $response->url('/login')->send(302); + $response->url('/login')->send(); } } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index dbeacb5..db08584 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -24,7 +24,7 @@ public function index(Request $request, Response $response): void } $uri = !Session::has('intended') ? config('app.home') : Session::pull('intended'); - $response->url($uri)->send(302); + $response->url($uri)->send(); } public function authenticate(Request $request, Response $response, LoginValidator $loginValidator): void @@ -35,10 +35,10 @@ public function authenticate(Request $request, Response $response, LoginValidato $uri = !Session::has('intended') ? config('app.home') : Session::pull('intended'); Alert::toast(__('welcome', ['name' => Auth::get('name')]))->success(); - $response->url($uri)->send(302); + $response->url($uri)->send(); } Alert::default(__('login_failed'))->error(); - $response->url('/login')->withInputs($request->only('email', 'password'))->withErrors([__('login_failed')])->send(302); + $response->url('/login')->withInputs($request->only('email', 'password'))->withErrors([__('login_failed')])->send(); } } diff --git a/app/Http/Controllers/Auth/LogoutController.php b/app/Http/Controllers/Auth/LogoutController.php index 59a8b71..76fcb75 100644 --- a/app/Http/Controllers/Auth/LogoutController.php +++ b/app/Http/Controllers/Auth/LogoutController.php @@ -19,6 +19,6 @@ public function __invoke(Response $response): void Auth::forget(); Alert::toast(__('logged_out'))->success(); - $response->url(config('app.home'))->send(302); + $response->url(config('app.home'))->send(); } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 0d89c9e..d3bdcb5 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -27,7 +27,7 @@ public function index(Request $request, Response $response): void } $uri = !Session::has('intended') ? config('app.home') : Session::pull('intended'); - $response->url($uri)->send(302); + $response->url($uri)->send(); } public function register(Request $request, Response $response, RegisterValidator $registerValidator, StoreAction $storeAction): void @@ -36,12 +36,12 @@ public function register(Request $request, Response $response, RegisterValidator $user = $storeAction->handle($validator->validated()); if (config('security.auth.email_verification')) { - $response->url('/email/notify?email=' . $user->email)->send(302); + $response->url('/email/notify?email=' . $user->email)->send(); } Mail::send(new WelcomeMail($user->email, $user->name)); Alert::default(__('account_created'))->success(); - $response->url('/login')->send(302); + $response->url('/login')->send(); } } diff --git a/app/Http/Middlewares/AccountPolicy.php b/app/Http/Middlewares/AccountPolicy.php index 76329e5..5d208e2 100644 --- a/app/Http/Middlewares/AccountPolicy.php +++ b/app/Http/Middlewares/AccountPolicy.php @@ -23,7 +23,7 @@ public function handle(Request $request, Response $response): void if (config('security.auth.email_verification')) { if (is_null(Auth::get('email_verified'))) { Alert::default(__('email_not_verifed'))->error(); - $response->url('/login')->intended($request->fullUri())->send(302); + $response->url('/login')->intended($request->fullUri())->send(); } } } diff --git a/app/Http/Middlewares/AuthPolicy.php b/app/Http/Middlewares/AuthPolicy.php index cf2cf8b..0fb1626 100644 --- a/app/Http/Middlewares/AuthPolicy.php +++ b/app/Http/Middlewares/AuthPolicy.php @@ -26,7 +26,7 @@ public function handle(Request $request, Response $response): void ->url('login') ->intended($request->fullUri()) ->withErrors([__('not_logged')]) - ->send(302); + ->send(); } } } diff --git a/core/Database/Connection/ConnectionInterface.php b/core/Database/Connection/ConnectionInterface.php index fb65bcb..48a0ccd 100644 --- a/core/Database/Connection/ConnectionInterface.php +++ b/core/Database/Connection/ConnectionInterface.php @@ -8,22 +8,19 @@ namespace Core\Database\Connection; -use PDO; -use PDOStatement; - interface ConnectionInterface { - public function getPDO(): PDO; + public function getPDO(); - public function executeStatement(string $query): false|int; + public function executeStatement(string $query); - public function executeQuery(string $query, array $args): false|PDOStatement; + public function executeQuery(string $query, array $args); - public function schemaExists(string $name): bool; + public function schemaExists(string $name); - public function tableExists(string $name): bool; + public function tableExists(string $name); - public function createSchema(string $name): void; + public function createSchema(string $name); - public function deleteSchema(string $name): void; + public function deleteSchema(string $name); } diff --git a/core/Database/Migration.php b/core/Database/Migration.php index babedc4..771b456 100644 --- a/core/Database/Migration.php +++ b/core/Database/Migration.php @@ -18,7 +18,7 @@ class Migration /** * @var \Core\Database\QueryBuilder */ - protected static $qb; + protected static mixed $qb; public static function createTable(string $name): self { diff --git a/core/Database/QueryBuilder.php b/core/Database/QueryBuilder.php index 9306c4f..40551c7 100644 --- a/core/Database/QueryBuilder.php +++ b/core/Database/QueryBuilder.php @@ -17,9 +17,9 @@ */ class QueryBuilder { - protected static $query = ''; - protected static $args = []; - protected static $table; + protected static string $query = ''; + protected static array $args = []; + protected static mixed $table; protected static function setTable(string $name): string { diff --git a/core/Database/Repository.php b/core/Database/Repository.php index 19f0bc3..d2515ee 100644 --- a/core/Database/Repository.php +++ b/core/Database/Repository.php @@ -19,7 +19,7 @@ class Repository { protected QueryBuilder $qb; - public function __construct(private string $table) {} + public function __construct(private readonly string $table) {} public function select(string ...$columns): self { diff --git a/core/Http/Client/Curl.php b/core/Http/Client/Curl.php index dd810d8..55a9af3 100644 --- a/core/Http/Client/Curl.php +++ b/core/Http/Client/Curl.php @@ -9,7 +9,6 @@ namespace Core\Http\Client; use Core\Exceptions\InvalidUrlFormatException; -use Core\Http\Client\ClientInterface; /** * Send asynchronous HTTP requests using curl diff --git a/core/Http/Response.php b/core/Http/Response.php index d2fcf5b..8ad1c85 100644 --- a/core/Http/Response.php +++ b/core/Http/Response.php @@ -144,7 +144,7 @@ public function json(array $data): self return $this; } - public function send(int $code = 200): void + public function send(int $code = 302): void { if (config('app.env') === 'test') { header('Session:' . json_encode($_SESSION)); diff --git a/core/Http/Validator/Validator.php b/core/Http/Validator/Validator.php index 1cc0098..b100782 100644 --- a/core/Http/Validator/Validator.php +++ b/core/Http/Validator/Validator.php @@ -10,7 +10,6 @@ use GUMP; use Core\Http\Response; -use Core\Http\Validator\ValidatorInterface; /** * Request fields validator diff --git a/core/Support/Helpers.php b/core/Support/Helpers.php index 777ca6c..baea388 100644 --- a/core/Support/Helpers.php +++ b/core/Support/Helpers.php @@ -17,15 +17,15 @@ /** * Cookies management */ -if (!function_exists('create_cookie')) { - function create_cookie(string $name, string $value, int $expire = 3600, bool $secure = false, string $domain = ''): bool +if (!function_exists('cookie_create')) { + function cookie_create(string $name, string $value, int $expire = 3600, bool $secure = false, string $domain = ''): bool { return Cookies::create($name, $value, $expire, $secure, $domain); } } -if (!function_exists('get_cookie')) { - function get_cookie(string $name): mixed +if (!function_exists('cookie_get')) { + function cookie_get(string $name): mixed { return Cookies::get($name); } @@ -38,8 +38,8 @@ function cookie_has(string $name): bool } } -if (!function_exists('delete_cookie')) { - function delete_cookie(string $name): bool +if (!function_exists('cookie_delete')) { + function cookie_delete(string $name): bool { return Cookies::delete($name); } @@ -48,8 +48,8 @@ function delete_cookie(string $name): bool /** * Sessions management */ -if (!function_exists('create_session')) { - function create_session(string $name, $data): void +if (!function_exists('session_create')) { + function session_create(string $name, $data): void { Session::create($name, $data); } @@ -155,7 +155,7 @@ function generate_csrf_token(): string $csrf_token = session_get('csrf_token'); } else { $csrf_token = generate_token(); - create_session('csrf_token', $csrf_token); + session_create('csrf_token', $csrf_token); } return $csrf_token;