refactor: fix code style

This commit is contained in:
Jay Trees 2024-05-29 17:08:43 +02:00
parent 262608544f
commit cf9e699ec9
31 changed files with 227 additions and 225 deletions

View file

@ -21,20 +21,20 @@ switch ($_SERVER['REQUEST_METHOD']) {
case 'GET': case 'GET':
if (isset($_GET['table'])) { if (isset($_GET['table'])) {
if ('all' === $_GET['table']) { if ('all' === $_GET['table']) {
$tables = array( $tables = [
'wishes', 'wishes',
'wishlists', 'wishlists',
'users', 'users',
); ];
$response['data'] = array(); $response['data'] = [];
foreach ($tables as $table) { foreach ($tables as $table) {
/** Get count */ /** Get count */
$countQuery = new Cache\Query( $countQuery = new Cache\Query(
'SELECT COUNT(`id`) AS "count" 'SELECT COUNT(`id`) AS "count"
FROM `' . $table . '`;', FROM `' . $table . '`;',
array(), [],
Duration::DAY Duration::DAY
); );

View file

@ -21,11 +21,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
$url_old = base64_decode($_GET['url']); $url_old = base64_decode($_GET['url']);
$url = new URL($url_old); $url = new URL($url_old);
$response['data'] = array( $response['data'] = [
'url' => $url_old, 'url' => $url_old,
'url_pretty' => $url->getPretty(), 'url_pretty' => $url->getPretty(),
'url_is_pretty' => $url->isPretty(), 'url_is_pretty' => $url->isPretty(),
); ];
} }
break; break;
} }

View file

@ -41,10 +41,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
LEFT OUTER JOIN `wishlists` ON `wishlists`.`id` = `wishlists_saved`.`wishlist` LEFT OUTER JOIN `wishlists` ON `wishlists`.`id` = `wishlists_saved`.`wishlist`
WHERE `wishlists_saved`.`user` = :user_id WHERE `wishlists_saved`.`user` = :user_id
AND `wishlist` = :wishlist_id;', AND `wishlist` = :wishlist_id;',
array( [
'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']), 'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']),
'user_id' => $user->getId() 'user_id' => $user->getId(),
) ]
) )
->fetch(); ->fetch();
@ -54,9 +54,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
->query( ->query(
'DELETE FROM `wishlists_saved` 'DELETE FROM `wishlists_saved`
WHERE `wishlist` = :wishlist_id', WHERE `wishlist` = :wishlist_id',
array( [
'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']) 'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']),
) ]
); );
$response['action'] = 'deleted'; $response['action'] = 'deleted';
@ -71,10 +71,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
:user_id, :user_id,
:wishlist_id :wishlist_id
);', );',
array( [
'user_id' => $user->getId(), 'user_id' => $user->getId(),
'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']), 'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']),
) ]
); );
$response['action'] = 'created'; $response['action'] = 'created';

View file

@ -32,16 +32,16 @@ switch ($_SERVER['REQUEST_METHOD']) {
:wishlist_name, :wishlist_name,
:wishlist_hash :wishlist_hash
);', );',
array( [
'user_id' => $user_id, 'user_id' => $user_id,
'wishlist_name' => $wishlist_name, 'wishlist_name' => $wishlist_name,
'wishlist_hash' => $wishlist_hash, 'wishlist_hash' => $wishlist_hash,
) ]
); );
$response['data'] = array( $response['data'] = [
'lastInsertId' => $database->lastInsertId(), 'lastInsertId' => $database->lastInsertId(),
); ];
} elseif (isset($_POST['wishlist-id'])) { } elseif (isset($_POST['wishlist-id'])) {
/** /**
* Request more wishes * Request more wishes
@ -55,9 +55,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
FROM `wishlists` FROM `wishlists`
WHERE `id` = :wishlist_id WHERE `id` = :wishlist_id
AND (`notification_sent` < (CURRENT_TIMESTAMP - INTERVAL 1 DAY) OR `notification_sent` IS NULL);', AND (`notification_sent` < (CURRENT_TIMESTAMP - INTERVAL 1 DAY) OR `notification_sent` IS NULL);',
array( [
'wishlist_id' => $wishlist_id, 'wishlist_id' => $wishlist_id,
) ]
); );
$wishlist = $wishlistQuery->fetch(); $wishlist = $wishlistQuery->fetch();
@ -90,9 +90,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
'UPDATE `wishlists` 'UPDATE `wishlists`
SET `notification_sent` = CURRENT_TIMESTAMP SET `notification_sent` = CURRENT_TIMESTAMP
WHERE `id` = :wishlist_id;', WHERE `id` = :wishlist_id;',
array( [
'wishlist_id' => $wishlist['id'], 'wishlist_id' => $wishlist['id'],
) ]
); );
} }
} }
@ -119,9 +119,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
'SELECT `id` 'SELECT `id`
FROM `wishlists` FROM `wishlists`
WHERE `user` = :wishlist_user_id', WHERE `user` = :wishlist_user_id',
array( [
'wishlist_user_id' => $user->getId(), 'wishlist_user_id' => $user->getId(),
) ]
); );
if (false === $wishlist || false === $userWishlistsQuery) { if (false === $wishlist || false === $userWishlistsQuery) {
@ -147,14 +147,14 @@ switch ($_SERVER['REQUEST_METHOD']) {
$priorityNone = 0; $priorityNone = 0;
$priority = (int) $_GET['priority'] ?? $priorityAll; $priority = (int) $_GET['priority'] ?? $priorityAll;
$options = array( $options = [
'style' => $_GET['style'], 'style' => $_GET['style'],
'placeholders' => array(), 'placeholders' => [],
); ];
$where = array( $where = [
'wishlist' => '`wishlist` = ' . $wishlist->getId(), 'wishlist' => '`wishlist` = ' . $wishlist->getId(),
'priority' => '`priority` = ' . $priority, 'priority' => '`priority` = ' . $priority,
); ];
if ($priorityAll === $priority) { if ($priorityAll === $priority) {
unset($where['priority']); unset($where['priority']);
@ -174,14 +174,14 @@ switch ($_SERVER['REQUEST_METHOD']) {
$priorityNone = 0; $priorityNone = 0;
$priority = (int) $_GET['priority'] ?? $priorityAll; $priority = (int) $_GET['priority'] ?? $priorityAll;
$options = array( $options = [
'style' => $_GET['style'], 'style' => $_GET['style'],
'placeholders' => array(), 'placeholders' => [],
); ];
$where = array( $where = [
'wishlist' => '`wishlist` = ' . $wishlist->getId(), 'wishlist' => '`wishlist` = ' . $wishlist->getId(),
'priority' => '`priority` = ' . $priority, 'priority' => '`priority` = ' . $priority,
); ];
if ($priorityAll === $priority) { if ($priorityAll === $priority) {
unset($where['priority']); unset($where['priority']);
@ -195,24 +195,24 @@ switch ($_SERVER['REQUEST_METHOD']) {
$response['results'] = $wishlist->getCards($options); $response['results'] = $wishlist->getCards($options);
} elseif ($getOwnWishlists) { } elseif ($getOwnWishlists) {
$wishlists = array(); $wishlists = [];
$wishlistsItems = array(); $wishlistsItems = [];
foreach ($user->getWishlists() as $wishlistData) { foreach ($user->getWishlists() as $wishlistData) {
$wishlist = new Wishlist($wishlistData); $wishlist = new Wishlist($wishlistData);
$wishlistId = $wishlist->getId(); $wishlistId = $wishlist->getId();
$wishlistName = $wishlist->getName(); $wishlistName = $wishlist->getName();
$wishlists[] = array( $wishlists[] = [
'id' => $wishlistId, 'id' => $wishlistId,
'hash' => $wishlist->getHash(), 'hash' => $wishlist->getHash(),
'userId' => $wishlist->getUserId(), 'userId' => $wishlist->getUserId(),
); ];
$wishlistsItems[] = array( $wishlistsItems[] = [
'name' => $wishlistName, 'name' => $wishlistName,
'value' => $wishlistId, 'value' => $wishlistId,
'text' => $wishlistName, 'text' => $wishlistName,
); ];
} }
$response['wishlists'] = $wishlists; $response['wishlists'] = $wishlists;
@ -236,10 +236,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
'UPDATE `wishlists` 'UPDATE `wishlists`
SET `name` = :wishlist_name SET `name` = :wishlist_name
WHERE `id` = :wishlist_id', WHERE `id` = :wishlist_id',
array( [
'wishlist_name' => Sanitiser::getTitle($_PUT['wishlist_title']), 'wishlist_name' => Sanitiser::getTitle($_PUT['wishlist_title']),
'wishlist_id' => Sanitiser::getNumber($_PUT['wishlist_id']), 'wishlist_id' => Sanitiser::getNumber($_PUT['wishlist_id']),
) ]
); );
$response['success'] = true; $response['success'] = true;
@ -259,9 +259,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
$database->query( $database->query(
'DELETE FROM `wishlists` 'DELETE FROM `wishlists`
WHERE `id` = :wishlist_id;', WHERE `id` = :wishlist_id;',
array( [
'wishlist_id' => Sanitiser::getNumber($_DELETE['wishlist_id']), 'wishlist_id' => Sanitiser::getNumber($_DELETE['wishlist_id']),
) ]
); );
$response['success'] = true; $response['success'] = true;

View file

@ -32,9 +32,9 @@ class API
if (file_exists($this->module_path)) { if (file_exists($this->module_path)) {
ob_start(); ob_start();
$response = array( $response = [
'success' => false, 'success' => false,
); ];
require $this->module_path; require $this->module_path;

View file

@ -52,11 +52,11 @@ class Blog
$next = $psots[$i + 1] ?? null; $next = $psots[$i + 1] ?? null;
if ($slug === $current->slug) { if ($slug === $current->slug) {
return array( return [
'previous' => $previous, 'previous' => $previous,
'current' => $current, 'current' => $current,
'next' => $next, 'next' => $next,
); ];
} }
} }
@ -116,7 +116,7 @@ class Blog
public static function getCategoriesHTML(array $categoryIDs): string public static function getCategoriesHTML(array $categoryIDs): string
{ {
$categoriesHTML = ''; $categoriesHTML = '';
$categoriesName = array(); $categoriesName = [];
foreach ($categoryIDs as $categoryID) { foreach ($categoryIDs as $categoryID) {
$category = self::get(sprintf(self::ENDPOINT_CATEGORIES, $categoryID)); $category = self::get(sprintf(self::ENDPOINT_CATEGORIES, $categoryID));

View file

@ -30,7 +30,7 @@ class Blog extends Cache
{ {
$filepath = $this->getFilepath(); $filepath = $this->getFilepath();
$response = $this->exists() ? json_decode(file_get_contents($filepath)) : array(); $response = $this->exists() ? json_decode(file_get_contents($filepath)) : [];
if (true === $this->generateCache() || empty($response)) { if (true === $this->generateCache() || empty($response)) {
$postsRemote = file_get_contents($this->url); $postsRemote = file_get_contents($this->url);

View file

@ -74,7 +74,7 @@ class Embed extends Cache
} }
if ($generateCache) { if ($generateCache) {
$ch_options = array( $ch_options = [
CURLOPT_AUTOREFERER => true, CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_FOLLOWLOCATION => true, CURLOPT_FOLLOWLOCATION => true,
@ -84,7 +84,7 @@ class Embed extends Cache
CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 30, CURLOPT_TIMEOUT => 30,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0', CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0',
); ];
/** Favicon */ /** Favicon */
if (str_contains(pathinfo($info->favicon, PATHINFO_EXTENSION), 'ico')) { if (str_contains(pathinfo($info->favicon, PATHINFO_EXTENSION), 'ico')) {

View file

@ -12,12 +12,12 @@ class Query extends Cache
* Private * Private
*/ */
private \wishthis\Database $database; private \wishthis\Database $database;
private array $placeholders = array(); private array $placeholders = [];
/** /**
* Public * Public
*/ */
public function __construct(string $url, array $placeholders = array(), int $maxAge = \wishthis\Duration::YEAR) public function __construct(string $url, array $placeholders = [], int $maxAge = \wishthis\Duration::YEAR)
{ {
global $database; global $database;
@ -31,7 +31,7 @@ class Query extends Cache
{ {
$filepath = $this->getFilepath(); $filepath = $this->getFilepath();
$response = $this->exists() ? json_decode(file_get_contents($filepath), true) : array(); $response = $this->exists() ? json_decode(file_get_contents($filepath), true) : [];
if (true === $this->generateCache()) { if (true === $this->generateCache()) {
$pdoStatement = $this->database $pdoStatement = $this->database

View file

@ -33,14 +33,14 @@ class Database
public function connect(): void public function connect(): void
{ {
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database . ';port=3306;charset=utf8mb4'; $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database . ';port=3306;charset=utf8mb4';
$options = array('placeholders' => array()); $options = ['placeholders' => []];
$this->pdo = new \PDO($dsn, $this->user, $this->password, $options); $this->pdo = new \PDO($dsn, $this->user, $this->password, $options);
} }
public function query(string $query, array $placeholders = array()): \PDOStatement|false public function query(string $query, array $placeholders = []): \PDOStatement|false
{ {
$statement = $this->pdo->prepare($query, array(\PDO::FETCH_ASSOC)); $statement = $this->pdo->prepare($query, [\PDO::FETCH_ASSOC]);
foreach ($placeholders as $name => $value) { foreach ($placeholders as $name => $value) {
switch (gettype($value)) { switch (gettype($value)) {
@ -103,10 +103,10 @@ class Database
FROM `INFORMATION_SCHEMA`.`COLUMNS` FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_NAME` = :table_name WHERE `TABLE_NAME` = :table_name
AND `COLUMN_NAME` = :column_name', AND `COLUMN_NAME` = :column_name',
array( [
'table_name' => $table_to_check, 'table_name' => $table_to_check,
'column_name' => $column_to_check, 'column_name' => $column_to_check,
) ]
) )
->fetch(); ->fetch();
$exists = false !== $result; $exists = false !== $result;

View file

@ -56,10 +56,10 @@ class Email
$to = $this->to; $to = $this->to;
$subject = $this->subject; $subject = $this->subject;
$message = $html; $message = $html;
$headers = array( $headers = [
'From' => 'no-reply@' . $_SERVER['HTTP_HOST'], 'From' => 'no-reply@' . $_SERVER['HTTP_HOST'],
'Content-type' => 'text/html; charset=utf-8', 'Content-type' => 'text/html; charset=utf-8',
); ];
$success = mail($to, $subject, $message, $headers); $success = mail($to, $subject, $message, $headers);

View file

@ -30,9 +30,9 @@ class Options
'SELECT * 'SELECT *
FROM `options` FROM `options`
WHERE `key` = :option_key', WHERE `key` = :option_key',
array( [
'option_key' => Sanitiser::getOption($key), 'option_key' => Sanitiser::getOption($key),
) ]
) )
->fetch(); ->fetch();
@ -51,9 +51,9 @@ class Options
'SELECT * 'SELECT *
FROM `options` FROM `options`
WHERE `key` = :option_key;', WHERE `key` = :option_key;',
array( [
'option_key' => $key, 'option_key' => $key,
) ]
) )
->rowCount(); ->rowCount();
@ -62,10 +62,10 @@ class Options
'UPDATE `options` 'UPDATE `options`
SET `value` = :option_value SET `value` = :option_value
WHERE `key` = :option_key;', WHERE `key` = :option_key;',
array( [
'option_value' => $value, 'option_value' => $value,
'option_key' => $key, 'option_key' => $key,
) ]
); );
} else { } else {
$this->database->query( $this->database->query(
@ -73,10 +73,10 @@ class Options
(`key`, `value`) (`key`, `value`)
VALUES VALUES
(:option_key, :option_value);', (:option_key, :option_value);',
array( [
'option_key' => $key, 'option_key' => $key,
'option_value' => $value, 'option_value' => $value,
) ]
); );
} }
} }

View file

@ -45,8 +45,8 @@ class Page
{ {
ob_start(); ob_start();
$containerClasses = array('ui', 'message', $class); $containerClasses = ['ui', 'message', $class];
$iconClasses = array('ui', 'icon'); $iconClasses = ['ui', 'icon'];
switch ($type) { switch ($type) {
case 'error': case 'error':
@ -120,12 +120,12 @@ class Page
*/ */
private string $name; private string $name;
public string $language = DEFAULT_LOCALE; public string $language = DEFAULT_LOCALE;
public array $messages = array(); public array $messages = [];
public string $link_preview; public string $link_preview;
public string $description; public string $description;
public array $stylesheets = array(); public array $stylesheets = [];
public array $scripts = array(); public array $scripts = [];
/** /**
* __construct * __construct
@ -185,12 +185,12 @@ class Page
/** /**
* Update * Update
*/ */
$ignoreUpdateRedirect = array( $ignoreUpdateRedirect = [
'maintenance', 'maintenance',
'login', 'login',
'logout', 'logout',
'update', 'update',
); ];
if ($options && $options->getOption('updateAvailable') && !in_array($this->name, $ignoreUpdateRedirect)) { if ($options && $options->getOption('updateAvailable') && !in_array($this->name, $ignoreUpdateRedirect)) {
if (100 === $user->getPower()) { if (100 === $user->getPower()) {
@ -251,20 +251,20 @@ class Page
/** /**
* Stylesheets * Stylesheets
*/ */
$this->stylesheets = array( $this->stylesheets = [
'fomantic-ui' => 'semantic/dist/semantic.min.css', 'fomantic-ui' => 'semantic/dist/semantic.min.css',
'default' => 'src/assets/css/default.css', 'default' => 'src/assets/css/default.css',
'dark' => 'src/assets/css/default/dark.css', 'dark' => 'src/assets/css/default/dark.css',
); ];
/** /**
* Scripts * Scripts
*/ */
$this->scripts = array( $this->scripts = [
'j-query' => 'node_modules/jquery/dist/jquery.min.js', 'j-query' => 'node_modules/jquery/dist/jquery.min.js',
'fomantic-ui' => 'semantic/dist/semantic.min.js', 'fomantic-ui' => 'semantic/dist/semantic.min.js',
'default' => 'src/assets/js/default.js', 'default' => 'src/assets/js/default.js',
); ];
/** html2canvas */ /** html2canvas */
$CrawlerDetect = new \Jaybizzle\CrawlerDetect\CrawlerDetect(); $CrawlerDetect = new \Jaybizzle\CrawlerDetect\CrawlerDetect();
@ -398,12 +398,12 @@ class Page
} }
/** AdSense */ /** AdSense */
$wishthis_hosts = array( $wishthis_hosts = [
'wishthis.localhost', 'wishthis.localhost',
'wishthis.online', 'wishthis.online',
'rc.wishthis.online', 'rc.wishthis.online',
'dev.wishthis.online', 'dev.wishthis.online',
); ];
$CrawlerDetect = new \Jaybizzle\CrawlerDetect\CrawlerDetect(); $CrawlerDetect = new \Jaybizzle\CrawlerDetect\CrawlerDetect();
if ( if (
@ -443,100 +443,100 @@ class Page
$login = Navigation::Login->value; $login = Navigation::Login->value;
$register = Navigation::Register->value; $register = Navigation::Register->value;
$pages = array( $pages = [
$blog => array( $blog => [
'text' => __('Blog'), 'text' => __('Blog'),
'alignment' => 'left', 'alignment' => 'left',
'items' => array( 'items' => [
array( [
'text' => __('Blog'), 'text' => __('Blog'),
'url' => self::PAGE_BLOG, 'url' => self::PAGE_BLOG,
'icon' => 'rss', 'icon' => 'rss',
), ],
), ],
), ],
$system => array( $system => [
'text' => __('System'), 'text' => __('System'),
'icon' => 'wrench', 'icon' => 'wrench',
'alignment' => 'right', 'alignment' => 'right',
'items' => array(), 'items' => [],
), ],
$account => array( $account => [
'text' => __('Account'), 'text' => __('Account'),
'icon' => 'user circle', 'icon' => 'user circle',
'alignment' => 'right', 'alignment' => 'right',
'items' => array(), 'items' => [],
), ],
); ];
if ($user->isLoggedIn()) { if ($user->isLoggedIn()) {
$pages[$wishlists] = array( $pages[$wishlists] = [
'text' => __('Wishlists'), 'text' => __('Wishlists'),
'alignment' => 'left', 'alignment' => 'left',
'items' => array( 'items' => [
array( [
'text' => __('My lists'), 'text' => __('My lists'),
'url' => Page::PAGE_WISHLISTS, 'url' => Page::PAGE_WISHLISTS,
'icon' => 'list', 'icon' => 'list',
), ],
array( [
'text' => __('Remembered lists'), 'text' => __('Remembered lists'),
'url' => Page::PAGE_WISHLISTS_SAVED, 'url' => Page::PAGE_WISHLISTS_SAVED,
'icon' => 'heart', 'icon' => 'heart',
), ],
), ],
); ];
} }
if ($user->isLoggedIn()) { if ($user->isLoggedIn()) {
$pages[$account]['items'][] = array( $pages[$account]['items'][] = [
'text' => __('Profile'), 'text' => __('Profile'),
'url' => Page::PAGE_PROFILE, 'url' => Page::PAGE_PROFILE,
'icon' => 'user circle alternate', 'icon' => 'user circle alternate',
); ];
if (100 === $user->getPower()) { if (100 === $user->getPower()) {
$pages[$account]['items'][] = array( $pages[$account]['items'][] = [
'text' => __('Login as'), 'text' => __('Login as'),
'url' => Page::PAGE_LOGIN_AS, 'url' => Page::PAGE_LOGIN_AS,
'icon' => 'sign out alternate', 'icon' => 'sign out alternate',
); ];
} }
$pages[$account]['items'][] = array( $pages[$account]['items'][] = [
'text' => __('Logout'), 'text' => __('Logout'),
'url' => Page::PAGE_LOGOUT, 'url' => Page::PAGE_LOGOUT,
'icon' => 'sign out alternate', 'icon' => 'sign out alternate',
); ];
} else { } else {
$pages[$login] = array( $pages[$login] = [
'text' => __('Login'), 'text' => __('Login'),
'alignment' => 'right', 'alignment' => 'right',
'items' => array( 'items' => [
array( [
'text' => __('Login'), 'text' => __('Login'),
'url' => Page::PAGE_LOGIN, 'url' => Page::PAGE_LOGIN,
'icon' => 'sign in alternate', 'icon' => 'sign in alternate',
), ],
), ],
); ];
$pages[$register] = array( $pages[$register] = [
'text' => __('Register'), 'text' => __('Register'),
'alignment' => 'right', 'alignment' => 'right',
'items' => array( 'items' => [
array( [
'text' => __('Register'), 'text' => __('Register'),
'url' => Page::PAGE_REGISTER, 'url' => Page::PAGE_REGISTER,
'icon' => 'user plus alternate', 'icon' => 'user plus alternate',
), ],
), ],
); ];
} }
if (100 === $user->getPower()) { if (100 === $user->getPower()) {
$pages[$system]['items'][] = array( $pages[$system]['items'][] = [
'text' => __('Settings'), 'text' => __('Settings'),
'url' => Page::PAGE_SETTINGS, 'url' => Page::PAGE_SETTINGS,
'icon' => 'cog', 'icon' => 'cog',
); ];
} }
ksort($pages); ksort($pages);

View file

@ -115,7 +115,8 @@ class Sanitiser
* *
* @return string * @return string
*/ */
public static function sanitiseText(string $text): string { public static function sanitiseText(string $text): string
{
$sanitisedText = \trim(\addslashes(\filter_var($text, \FILTER_SANITIZE_SPECIAL_CHARS))); $sanitisedText = \trim(\addslashes(\filter_var($text, \FILTER_SANITIZE_SPECIAL_CHARS)));
return $sanitisedText; return $sanitisedText;
@ -128,7 +129,8 @@ class Sanitiser
* *
* @return string * @return string
*/ */
public static function sanitiseEmail(string $email): string { public static function sanitiseEmail(string $email): string
{
$sanitisedEmail = \trim(\addslashes(\filter_var($email, \FILTER_SANITIZE_EMAIL))); $sanitisedEmail = \trim(\addslashes(\filter_var($email, \FILTER_SANITIZE_EMAIL)));
return $sanitisedEmail; return $sanitisedEmail;

View file

@ -19,7 +19,7 @@ class URL
*/ */
public static function getResponseCode(string $url): int public static function getResponseCode(string $url): int
{ {
$ch_options = array( $ch_options = [
CURLOPT_AUTOREFERER => true, CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_FOLLOWLOCATION => true, CURLOPT_FOLLOWLOCATION => true,
@ -29,7 +29,7 @@ class URL
CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 30, CURLOPT_TIMEOUT => 30,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0', CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0',
); ];
$ch = curl_init($url); $ch = curl_init($url);
curl_setopt_array($ch, $ch_options); curl_setopt_array($ch, $ch_options);
@ -159,7 +159,7 @@ class URL
}, },
explode('&', parse_url($target, PHP_URL_QUERY)) explode('&', parse_url($target, PHP_URL_QUERY))
); );
$flags = explode(',', substr($parts[3], 1, -1)) ?? array(); $flags = explode(',', substr($parts[3], 1, -1)) ?? [];
\parse_str(\parse_url($target, PHP_URL_QUERY), $parameters); \parse_str(\parse_url($target, PHP_URL_QUERY), $parameters);
/** */ /** */
@ -185,7 +185,7 @@ class URL
} }
$match = preg_match( $match = preg_match(
'/^' . str_replace(array('/'), array('\/'), $rewriteRule) . '$/', '/^' . str_replace(['/'], ['\/'], $rewriteRule) . '$/',
$potential_url $potential_url
); );
@ -212,14 +212,14 @@ class URL
public function getGET(): array public function getGET(): array
{ {
$queryString = $this->url; $queryString = $this->url;
$GET = array(); $GET = [];
if ($this->isPretty()) { if ($this->isPretty()) {
$queryString = parse_url($this->getPermalink(), PHP_URL_QUERY); $queryString = parse_url($this->getPermalink(), PHP_URL_QUERY);
} }
if (null === $queryString) { if (null === $queryString) {
return array(); return [];
} }
if ('/?' === substr($queryString, 0, 2)) { if ('/?' === substr($queryString, 0, 2)) {

View file

@ -26,26 +26,26 @@ class Wish
public const STATUS_FULFILLED = 'fulfilled'; public const STATUS_FULFILLED = 'fulfilled';
public static array $priorities; public static array $priorities;
public static array $affiliates = array( public static array $affiliates = [
'amazon.de' => 'grandel0b-21', 'amazon.de' => 'grandel0b-21',
); ];
public static function initialize() public static function initialize()
{ {
self::$priorities = array( self::$priorities = [
'1' => array( '1' => [
'name' => __('Unsure about it'), 'name' => __('Unsure about it'),
'color' => 'teal', 'color' => 'teal',
), ],
'2' => array( '2' => [
'name' => __('Nice to have'), 'name' => __('Nice to have'),
'color' => 'olive', 'color' => 'olive',
), ],
'3' => array( '3' => [
'name' => __('Would love it'), 'name' => __('Would love it'),
'color' => 'yellow', 'color' => 'yellow',
), ],
); ];
} }
public static function getFromId(int $wishId): self|false public static function getFromId(int $wishId): self|false
@ -57,9 +57,9 @@ class Wish
FROM `wishes` FROM `wishes`
LEFT JOIN `products` ON `wishes`.`id` = `products`.`wish` LEFT JOIN `products` ON `wishes`.`id` = `products`.`wish`
WHERE `wishes`.`id` = :wish_id', WHERE `wishes`.`id` = :wish_id',
array( [
'wish_id' => $wishId, 'wish_id' => $wishId,
) ]
); );
if (false === $wishQuery) { if (false === $wishQuery) {
@ -79,7 +79,7 @@ class Wish
if (isset($urlParts['query'])) { if (isset($urlParts['query'])) {
\parse_str($urlParts['query'], $urlParameters); \parse_str($urlParts['query'], $urlParameters);
} else { } else {
$urlParameters = array(); $urlParameters = [];
} }
foreach (self::$affiliates as $host => $tagId) { foreach (self::$affiliates as $host => $tagId) {
@ -102,7 +102,7 @@ class Wish
if (isset($urlParts['query'])) { if (isset($urlParts['query'])) {
\parse_str($urlParts['query'], $urlParameters); \parse_str($urlParts['query'], $urlParameters);
} else { } else {
$urlParameters = array(); $urlParameters = [];
} }
foreach (self::$affiliates as $host => $tagId) { foreach (self::$affiliates as $host => $tagId) {
@ -439,7 +439,7 @@ class Wish
public function serialise(): array public function serialise(): array
{ {
$wishArray = array( $wishArray = [
'id' => $this->id, 'id' => $this->id,
'wishlist' => $this->wishlist, 'wishlist' => $this->wishlist,
'title' => $this->title, 'title' => $this->title,
@ -451,7 +451,7 @@ class Wish
'is_purchasable' => $this->is_purchasable, 'is_purchasable' => $this->is_purchasable,
'edited' => $this->edited, 'edited' => $this->edited,
'price' => $this->price, 'price' => $this->price,
); ];
return $wishArray; return $wishArray;
} }

View file

@ -18,9 +18,9 @@ class Wishlist
'SELECT * 'SELECT *
FROM `wishlists` FROM `wishlists`
WHERE `wishlists`.`id` = :wishlist_id', WHERE `wishlists`.`id` = :wishlist_id',
array( [
'wishlist_id' => $id, 'wishlist_id' => $id,
) ]
); );
if (false === $wishlistQuery) { if (false === $wishlistQuery) {
@ -46,9 +46,9 @@ class Wishlist
'SELECT * 'SELECT *
FROM `wishlists` FROM `wishlists`
WHERE `wishlists`.`hash` = :wishlist_hash', WHERE `wishlists`.`hash` = :wishlist_hash',
array( [
'wishlist_hash' => $hash, 'wishlist_hash' => $hash,
) ]
); );
$wishlistData = $wishlistQuery->fetch(); $wishlistData = $wishlistQuery->fetch();
@ -100,7 +100,7 @@ class Wishlist
*/ */
private int $notification_sent; private int $notification_sent;
public array $wishes = array(); public array $wishes = [];
public bool $exists = false; public bool $exists = false;
@ -113,7 +113,7 @@ class Wishlist
$this->notification_sent = $wishlist_data['notification_sent'] ? \strtotime($wishlist_data['notification_sent']) : 0; $this->notification_sent = $wishlist_data['notification_sent'] ? \strtotime($wishlist_data['notification_sent']) : 0;
} }
public function getWishes(array $options = array('placeholders' => array())): array public function getWishes(array $options = ['placeholders' => []]): array
{ {
global $database; global $database;
@ -173,7 +173,7 @@ class Wishlist
return $this->wishes; return $this->wishes;
} }
public function getCards(array $options = array('placeholders' => array())): string public function getCards(array $options = ['placeholders' => []]): string
{ {
ob_start(); ob_start();

View file

@ -48,9 +48,9 @@ $user = User::getCurrent();
WHERE `users`.`id` = :user_id WHERE `users`.`id` = :user_id
ORDER BY `wishes`.`edited` DESC ORDER BY `wishes`.`edited` DESC
LIMIT 1;', LIMIT 1;',
array( [
'user_id' => $user->getId(), 'user_id' => $user->getId(),
) ]
); );
if (false !== $lastWishlistQuery && 1 === $lastWishlistQuery->rowCount()) { if (false !== $lastWishlistQuery && 1 === $lastWishlistQuery->rowCount()) {

View file

@ -19,9 +19,9 @@ if (isset($_POST['email'])) {
'SELECT * 'SELECT *
FROM `users` FROM `users`
WHERE `email` = :user_email;', WHERE `email` = :user_email;',
array( [
'user_email' => $email, 'user_email' => $email,
) ]
); );
$success = false !== $userQuery; $success = false !== $userQuery;

View file

@ -46,9 +46,9 @@ if (isset($_POST['reset'], $_POST['email'])) {
'SELECT * 'SELECT *
FROM `users` FROM `users`
WHERE `email` = :user_email;', WHERE `email` = :user_email;',
array( [
'user_email' => Sanitiser::getEmail($_POST['email']), 'user_email' => Sanitiser::getEmail($_POST['email']),
) ]
); );
$user = false !== $userQuery ? new User($userQuery->fetch()) : new User(); $user = false !== $userQuery ? new User($userQuery->fetch()) : new User();
@ -62,10 +62,10 @@ if (isset($_POST['reset'], $_POST['email'])) {
SET `password_reset_token` = :user_password_reset_token, SET `password_reset_token` = :user_password_reset_token,
`password_reset_valid_until` = :user_reset_valid_until `password_reset_valid_until` = :user_reset_valid_until
WHERE `id` = ' . $user->getId() . ';', WHERE `id` = ' . $user->getId() . ';',
array( [
'user_password_reset_token' => $token, 'user_password_reset_token' => $token,
'user_reset_valid_until' => date('Y-m-d H:i:s', $validUntil), 'user_reset_valid_until' => date('Y-m-d H:i:s', $validUntil),
) ]
); );
$emailReset = new Email($_POST['email'], __('Password reset link', null, $user), 'default', 'password-reset'); $emailReset = new Email($_POST['email'], __('Password reset link', null, $user), 'default', 'password-reset');

View file

@ -19,10 +19,10 @@ if (
'UPDATE `users` 'UPDATE `users`
SET `password` = :password SET `password` = :password
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'password' => $password, 'password' => $password,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$loginRequired = true; $loginRequired = true;

View file

@ -17,10 +17,10 @@ if (isset($_POST['user-name-first'])) {
'UPDATE `users` 'UPDATE `users`
SET `name_first` = :name_first SET `name_first` = :name_first
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'name_first' => $nameFirst, 'name_first' => $nameFirst,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setNameFirst($nameFirst); $user->setNameFirst($nameFirst);
@ -47,10 +47,10 @@ if (isset($_POST['user-name-last'])) {
'UPDATE `users` 'UPDATE `users`
SET `name_last` = :name_last SET `name_last` = :name_last
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'name_last' => $nameLast, 'name_last' => $nameLast,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setNameLast($nameLast); $user->setNameLast($nameLast);
@ -77,10 +77,10 @@ if (isset($_POST['user-name-nick'])) {
'UPDATE `users` 'UPDATE `users`
SET `name_nick` = :name_nick SET `name_nick` = :name_nick
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'name_nick' => $nameNick, 'name_nick' => $nameNick,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setNameNick($nameNick); $user->setNameNick($nameNick);
@ -107,10 +107,10 @@ if (isset($_POST['user-email'])) {
'UPDATE `users` 'UPDATE `users`
SET `email` = :email SET `email` = :email
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'email' => $email, 'email' => $email,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setEmail($email); $user->setEmail($email);
@ -140,10 +140,10 @@ if (isset($_POST['user-birthdate'])) {
'UPDATE `users` 'UPDATE `users`
SET `birthdate` = :birthdate SET `birthdate` = :birthdate
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'birthdate' => $birthdate, 'birthdate' => $birthdate,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setBirthdate($birthdate); $user->setBirthdate($birthdate);

View file

@ -24,10 +24,10 @@ if (isset($_POST['user-language'])) {
'UPDATE `users` 'UPDATE `users`
SET `language` = :language SET `language` = :language
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'language' => $userLocale, 'language' => $userLocale,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setLocale($userLocale); $user->setLocale($userLocale);
@ -61,10 +61,10 @@ if (isset($_POST['user-currency'])) {
'UPDATE `users` 'UPDATE `users`
SET `currency` = :currency SET `currency` = :currency
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'currency' => $userCurrency, 'currency' => $userCurrency,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setCurrency($userCurrency); $user->setCurrency($userCurrency);
@ -92,17 +92,17 @@ if (isset($_POST['user-channel'])) {
}, },
CHANNELS CHANNELS
) )
: array(); : [];
if (\in_array($userChannel, $channels, true) && $userChannel !== $user->getChannel()) { if (\in_array($userChannel, $channels, true) && $userChannel !== $user->getChannel()) {
$database->query( $database->query(
'UPDATE `users` 'UPDATE `users`
SET `channel` = :channel SET `channel` = :channel
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'channel' => $userChannel, 'channel' => $userChannel,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setChannel($userChannel); $user->setChannel($userChannel);
@ -122,10 +122,10 @@ if (isset($_POST['user-channel'])) {
'UPDATE `users` 'UPDATE `users`
SET `channel` = :channel SET `channel` = :channel
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'channel' => null, 'channel' => null,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setChannel($userChannel); $user->setChannel($userChannel);
@ -147,10 +147,10 @@ if ($userAdvertisements !== $user->getAdvertisements()) {
'UPDATE `users` 'UPDATE `users`
SET `advertisements` = :advertisements SET `advertisements` = :advertisements
WHERE `id` = :user_id', WHERE `id` = :user_id',
array( [
'advertisements' => $userAdvertisements, 'advertisements' => $userAdvertisements,
'user_id' => $userId, 'user_id' => $userId,
) ]
); );
$user->setAdvertisements($userAdvertisements); $user->setAdvertisements($userAdvertisements);

View file

@ -205,7 +205,7 @@ $page->navigation();
<select class="ui search dropdown currency" name="user-currency"> <select class="ui search dropdown currency" name="user-currency">
<?php <?php
$currencies = array(); $currencies = [];
?> ?>
<?php foreach ($locales as $locale) { ?> <?php foreach ($locales as $locale) { ?>

View file

@ -33,7 +33,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
$isHuman = false; $isHuman = false;
$planet = strtolower(Sanitiser::getTitle($_POST['planet'])); $planet = strtolower(Sanitiser::getTitle($_POST['planet']));
$planetName = strtoupper($planet[0]) . substr($planet, 1); $planetName = strtoupper($planet[0]) . substr($planet, 1);
$planets = array( $planets = [
strtolower(__('Mercury')), strtolower(__('Mercury')),
strtolower(__('Venus')), strtolower(__('Venus')),
strtolower(__('Earth')), strtolower(__('Earth')),
@ -42,11 +42,11 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
strtolower(__('Saturn')), strtolower(__('Saturn')),
strtolower(__('Uranus')), strtolower(__('Uranus')),
strtolower(__('Neptune')), strtolower(__('Neptune')),
); ];
$not_planets = array( $not_planets = [
strtolower(__('Pluto')), strtolower(__('Pluto')),
strtolower(__('Sun')), strtolower(__('Sun')),
); ];
if (in_array($planet, array_merge($planets, $not_planets))) { if (in_array($planet, array_merge($planets, $not_planets))) {
$isHuman = true; $isHuman = true;
@ -75,10 +75,10 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
FROM `users` FROM `users`
WHERE `email` = :user_email WHERE `email` = :user_email
AND `password_reset_token` = :user_password_reset_token', AND `password_reset_token` = :user_password_reset_token',
array( [
'user_email' => $user_email, 'user_email' => $user_email,
'user_password_reset_token' => $user_token, 'user_password_reset_token' => $user_token,
) ]
); );
if (false !== $userQuery) { if (false !== $userQuery) {
@ -91,10 +91,10 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
'UPDATE `users` 'UPDATE `users`
SET `password` = :user_password SET `password` = :user_password
WHERE `id` = :user_id;', WHERE `id` = :user_id;',
array( [
'user_password' => User::passwordToHash($_POST['password']), 'user_password' => User::passwordToHash($_POST['password']),
'user_id' => $user->getId(), 'user_id' => $user->getId(),
) ]
); );
$page->messages[] = Page::success( $page->messages[] = Page::success(
@ -140,11 +140,11 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
100, 100,
:user_language :user_language
);', );',
array( [
'user_email' => $user_email, 'user_email' => $user_email,
'user_password' => User::passwordToHash($_POST['password']), 'user_password' => User::passwordToHash($_POST['password']),
'user_language' => $locale_user, 'user_language' => $locale_user,
) ]
); );
$userRegistered = true; $userRegistered = true;
} else { } else {
@ -164,11 +164,11 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
:user_password, :user_password,
:user_language :user_language
);', );',
array( [
'user_email' => $user_email, 'user_email' => $user_email,
'user_password' => User::passwordToHash($_POST['password']), 'user_password' => User::passwordToHash($_POST['password']),
'user_language' => $locale_user, 'user_language' => $locale_user,
) ]
); );
$userRegistered = true; $userRegistered = true;
@ -196,11 +196,11 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
:wishlist_name, :wishlist_name,
:wishlist_hash :wishlist_hash
);', );',
array( [
'wishlist_user_id' => $user_id, 'wishlist_user_id' => $user_id,
'wishlist_name' => $wishlist_name, 'wishlist_name' => $wishlist_name,
'wishlist_hash' => $wishlist_hash, 'wishlist_hash' => $wishlist_hash,
) ]
); );
} }
} else { } else {

View file

@ -16,17 +16,17 @@ $page = new Page(__FILE__, __('Update'), 100);
if ('POST' === $_SERVER['REQUEST_METHOD']) { if ('POST' === $_SERVER['REQUEST_METHOD']) {
$versions_directory = ROOT . '/src/update'; $versions_directory = ROOT . '/src/update';
$versions_contents = scandir($versions_directory); $versions_contents = scandir($versions_directory);
$versions = array(); $versions = [];
foreach ($versions_contents as $filename) { foreach ($versions_contents as $filename) {
$filepath = $versions_directory . '/' . $filename; $filepath = $versions_directory . '/' . $filename;
$pathinfo = pathinfo($filepath); $pathinfo = pathinfo($filepath);
if ('sql' === $pathinfo['extension']) { if ('sql' === $pathinfo['extension']) {
$versions[] = array( $versions[] = [
'version' => str_replace('-', '.', $pathinfo['filename']), 'version' => str_replace('-', '.', $pathinfo['filename']),
'filepath' => $filepath, 'filepath' => $filepath,
); ];
} }
} }

View file

@ -16,7 +16,7 @@ $page->navigation();
$user = User::getCurrent(); $user = User::getCurrent();
$wishlists = $user->getSavedWishlists(); $wishlists = $user->getSavedWishlists();
$wishlists_by_user = array(); $wishlists_by_user = [];
foreach ($wishlists as $wishlist_saved) { foreach ($wishlists as $wishlist_saved) {
if (!isset($wishlist_saved['user'])) { if (!isset($wishlist_saved['user'])) {

View file

@ -10,7 +10,7 @@ final class CreateWishTest extends TestCase
{ {
private int $testWishlistId = 5; private int $testWishlistId = 5;
private function apiRequest(string $endpoint, int $method, array $data = array()): string|false private function apiRequest(string $endpoint, int $method, array $data = []): string|false
{ {
$queryString = http_build_query($data); $queryString = http_build_query($data);
@ -32,10 +32,10 @@ final class CreateWishTest extends TestCase
$apiResponse = $this->apiRequest( $apiResponse = $this->apiRequest(
'http://wishthis.online.localhost/api/wishes', 'http://wishthis.online.localhost/api/wishes',
\CURLOPT_POST, \CURLOPT_POST,
array( [
'wish_title' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories', 'wish_title' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories',
'wishlist_id' => $this->testWishlistId, 'wishlist_id' => $this->testWishlistId,
) ]
); );
$this->assertNotFalse($apiResponse); $this->assertNotFalse($apiResponse);
@ -50,10 +50,10 @@ final class CreateWishTest extends TestCase
$apiResponse = $this->apiRequest( $apiResponse = $this->apiRequest(
'http://wishthis.online.localhost/api/wishes', 'http://wishthis.online.localhost/api/wishes',
\CURLOPT_POST, \CURLOPT_POST,
array( [
'wish_title' => '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', 'wish_title' => '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789',
'wishlist_id' => $this->testWishlistId, 'wishlist_id' => $this->testWishlistId,
) ]
); );
$this->assertNotFalse($apiResponse); $this->assertNotFalse($apiResponse);
@ -93,10 +93,10 @@ final class CreateWishTest extends TestCase
$apiResponse = $this->apiRequest( $apiResponse = $this->apiRequest(
'http://wishthis.online.localhost/api/wishes', 'http://wishthis.online.localhost/api/wishes',
\CURLOPT_POST, \CURLOPT_POST,
array( [
'wish_description' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories', 'wish_description' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories',
'wishlist_id' => $this->testWishlistId, 'wishlist_id' => $this->testWishlistId,
) ]
); );
$this->assertNotFalse($apiResponse); $this->assertNotFalse($apiResponse);
@ -111,10 +111,10 @@ final class CreateWishTest extends TestCase
$apiResponse = $this->apiRequest( $apiResponse = $this->apiRequest(
'http://wishthis.online.localhost/api/wishes', 'http://wishthis.online.localhost/api/wishes',
\CURLOPT_POST, \CURLOPT_POST,
array( [
'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261', 'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261',
'wishlist_id' => $this->testWishlistId, 'wishlist_id' => $this->testWishlistId,
) ]
); );
$this->assertNotFalse($apiResponse); $this->assertNotFalse($apiResponse);
@ -129,10 +129,10 @@ final class CreateWishTest extends TestCase
$apiResponse = $this->apiRequest( $apiResponse = $this->apiRequest(
'http://wishthis.online.localhost/api/wishes', 'http://wishthis.online.localhost/api/wishes',
\CURLOPT_POST, \CURLOPT_POST,
array( [
'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261?012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', 'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261?012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789',
'wishlist_id' => $this->testWishlistId, 'wishlist_id' => $this->testWishlistId,
) ]
); );
$this->assertNotFalse($apiResponse); $this->assertNotFalse($apiResponse);

View file

@ -36,10 +36,10 @@ final class LogInTest extends TestCase
'REPLACE INTO `users` 'REPLACE INTO `users`
(`email`, `password`) VALUES (`email`, `password`) VALUES
(:userEmail, :userPassword)', (:userEmail, :userPassword)',
array( [
'userEmail' => $userEmail, 'userEmail' => $userEmail,
'userPassword' => $userPassword, 'userPassword' => $userPassword,
) ]
); );
$userLoginSuccessful = $user->logIn($userEmail, $userPassword); $userLoginSuccessful = $user->logIn($userEmail, $userPassword);

View file

@ -13,20 +13,20 @@ final class PrettyUrlTest extends TestCase
{ {
\define('ROOT', \dirname(__DIR__)); \define('ROOT', \dirname(__DIR__));
$requestUris = array( $requestUris = [
'//api/database-test', '//api/database-test',
'/api/database-test', '/api/database-test',
'api/database-test', 'api/database-test',
'http://wishthis.online.localhost/index.php/api/database-test', 'http://wishthis.online.localhost/index.php/api/database-test',
'http://wishthis.online.localhost/index.php//api/database-test', 'http://wishthis.online.localhost/index.php//api/database-test',
); ];
require __DIR__ . '/../src/classes/wishthis/URL.php'; require __DIR__ . '/../src/classes/wishthis/URL.php';
$expected_GET = array( $expected_GET = [
'page' => 'api', 'page' => 'api',
'module' => 'database-test', 'module' => 'database-test',
); ];
foreach ($requestUris as $requestUri) { foreach ($requestUris as $requestUri) {
$url = new URL($requestUri); $url = new URL($requestUri);