refactor: apply new style

This commit is contained in:
grandeljay 2024-01-16 17:35:38 +01:00
parent 505e398aa4
commit 7735b267b5

View file

@ -19,9 +19,9 @@ class User
'SELECT * 'SELECT *
FROM `users` FROM `users`
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'user_id' => $user_id, 'user_id' => $user_id,
) ]
); );
if (false !== $userQuery) { if (false !== $userQuery) {
@ -169,7 +169,7 @@ class User
*/ */
public ?\Gettext\Translations $translations = null; public ?\Gettext\Translations $translations = null;
public function __construct(array $fields = array()) public function __construct(array $fields = [])
{ {
if (!empty($fields)) { if (!empty($fields)) {
$this->id = $fields['id']; $this->id = $fields['id'];
@ -266,9 +266,9 @@ class User
'SELECT * 'SELECT *
FROM `sessions` FROM `sessions`
WHERE `session` = :session', WHERE `session` = :session',
array( [
'session' => $_COOKIE['wishthis_session'], 'session' => $_COOKIE['wishthis_session'],
) ]
) )
->fetchAll(\PDO::FETCH_ASSOC); ->fetchAll(\PDO::FETCH_ASSOC);
@ -299,9 +299,9 @@ class User
'SELECT * 'SELECT *
FROM `wishlists` FROM `wishlists`
WHERE `user` = :user_id;', WHERE `user` = :user_id;',
array( [
'user_id' => $this->id, 'user_id' => $this->id,
) ]
) )
->fetchAll(); ->fetchAll();
@ -312,7 +312,7 @@ class User
{ {
global $database; global $database;
$wishlists = array(); $wishlists = [];
if (!$this->isLoggedIn()) { if (!$this->isLoggedIn()) {
return $wishlists; return $wishlists;
@ -326,9 +326,9 @@ class User
FROM `wishlists_saved` FROM `wishlists_saved`
LEFT JOIN `wishlists` ON `wishlists`.`id` = `wishlists_saved`.`wishlist` LEFT JOIN `wishlists` ON `wishlists`.`id` = `wishlists_saved`.`wishlist`
WHERE `wishlists_saved`.`user` = :user_id;', WHERE `wishlists_saved`.`user` = :user_id;',
array( [
'user_id' => $this->id, 'user_id' => $this->id,
) ]
) )
->fetchAll(\PDO::FETCH_ASSOC); ->fetchAll(\PDO::FETCH_ASSOC);
@ -377,10 +377,10 @@ class User
FROM `users` FROM `users`
WHERE `email` = :user_email WHERE `email` = :user_email
AND `password` = :user_password;', AND `password` = :user_password;',
array( [
'user_email' => $email, 'user_email' => $email,
'user_password' => $password, 'user_password' => $password,
) ]
) )
->fetch(\PDO::FETCH_ASSOC); ->fetch(\PDO::FETCH_ASSOC);
@ -401,10 +401,10 @@ class User
SET `last_login` = NOW() SET `last_login` = NOW()
WHERE `email` = :user_email WHERE `email` = :user_email
AND `password` = :user_password;', AND `password` = :user_password;',
array( [
'user_email' => $email, 'user_email' => $email,
'user_password' => $password, 'user_password' => $password,
) ]
); );
$user_database_fields['last_login'] = date('Y-m-d H:i'); $user_database_fields['last_login'] = date('Y-m-d H:i');
@ -442,9 +442,9 @@ class User
->query( ->query(
'DELETE FROM `sessions` 'DELETE FROM `sessions`
WHERE `session` = :session', WHERE `session` = :session',
array( [
'session' => $_COOKIE['wishthis'], 'session' => $_COOKIE['wishthis'],
) ]
); );
session_destroy(); session_destroy();
@ -461,9 +461,9 @@ class User
$database->query( $database->query(
'DELETE FROM `users` 'DELETE FROM `users`
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'user_id' => $this->id, 'user_id' => $this->id,
) ]
); );
} }
@ -598,9 +598,9 @@ class User
'SELECT * 'SELECT *
FROM `sessions` FROM `sessions`
WHERE `session` = :session', WHERE `session` = :session',
array( [
'session' => $sessionId, 'session' => $sessionId,
) ]
) )
->fetchAll(); ->fetchAll();
@ -613,11 +613,11 @@ class User
SET `expires` = :expires SET `expires` = :expires
WHERE `session` = :session WHERE `session` = :session
AND `user` = :user', AND `user` = :user',
array( [
'expires' => date('Y-m-d H:i', $sessionExpires), 'expires' => date('Y-m-d H:i', $sessionExpires),
'session' => $sessionId, 'session' => $sessionId,
'user' => $forUser, 'user' => $forUser,
) ]
); );
/** There's no need to do anything further. */ /** There's no need to do anything further. */
@ -636,11 +636,11 @@ class User
:session_id, :session_id,
:session_expires :session_expires
)', )',
array( [
'user_id' => $forUser, 'user_id' => $forUser,
'session_id' => $sessionId, 'session_id' => $sessionId,
'session_expires' => date('Y-m-d H:i', time() + $sessionDurationSeconds), 'session_expires' => date('Y-m-d H:i', time() + $sessionDurationSeconds),
) ]
); );
} }
@ -663,9 +663,9 @@ class User
'SELECT * 'SELECT *
FROM `sessions` FROM `sessions`
WHERE `session` = :session', WHERE `session` = :session',
array( [
'session' => $_COOKIE['wishthis_session'], 'session' => $_COOKIE['wishthis_session'],
) ]
) )
->fetch(\PDO::FETCH_ASSOC); ->fetch(\PDO::FETCH_ASSOC);
@ -678,9 +678,9 @@ class User
'SELECT * 'SELECT *
FROM `users` FROM `users`
WHERE `id` = :user', WHERE `id` = :user',
array( [
'user' => $session['user'], 'user' => $session['user'],
) ]
) )
->fetch(\PDO::FETCH_ASSOC); ->fetch(\PDO::FETCH_ASSOC);