From 2ac4bdca2ab38990f891371282a3a17af290e78f Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 1 Dec 2024 18:09:09 +0100 Subject: PHP Keywords and types should be in lowercase Follow PSR-12 and use lowercase variants of PHP reserved keywords. See: https://www.php-fig.org/psr/psr-12/#25-keywords-and-types Find all uppercase occurrences of "or", "and", "null", "true" and "false" and change them to the lowercase variant. --- core/namespace/Application.php | 12 +++---- core/namespace/Factory.php | 2 +- core/namespace/HTTP.php | 38 +++++++++++----------- core/namespace/Language.php | 4 +-- core/namespace/Migrator.php | 2 +- core/namespace/ORM/Entity.php | 2 +- .../ORM/Repositories/CategoryRepository.php | 4 +-- core/namespace/ORM/Repository.php | 10 +++--- core/namespace/ORM/RepositorySearch.php | 6 ++-- core/namespace/Parsers/ArgumentParser.php | 4 +-- core/namespace/Parsers/MarkdownParser.php | 2 +- core/namespace/Router.php | 6 ++-- core/namespace/Template/Template.php | 2 +- 13 files changed, 47 insertions(+), 47 deletions(-) (limited to 'core/namespace') diff --git a/core/namespace/Application.php b/core/namespace/Application.php index 2d5a23c..3dee818 100644 --- a/core/namespace/Application.php +++ b/core/namespace/Application.php @@ -29,7 +29,7 @@ class Application { # Get configuration value #=============================================================================== public static function get($config) { - return self::$configuration[$config] ?? NULL; + return self::$configuration[$config] ?? null; } #=============================================================================== @@ -42,8 +42,8 @@ class Application { #=============================================================================== # Return singleton Database instance #=============================================================================== - public static function getDatabase($force = FALSE): Database { - if(!self::$Database instanceof Database OR $force === TRUE) { + public static function getDatabase($force = false): Database { + if(!self::$Database instanceof Database or $force === true) { $hostname = self::get('DATABASE.HOSTNAME'); $basename = self::get('DATABASE.BASENAME'); $username = self::get('DATABASE.USERNAME'); @@ -70,8 +70,8 @@ class Application { #=============================================================================== # Return singleton Language instance #=============================================================================== - public static function getLanguage($force = FALSE): Language { - if(!self::$Language instanceof Language OR $force === TRUE) { + public static function getLanguage($force = false): Language { + if(!self::$Language instanceof Language or $force === true) { $template_name = self::get('TEMPLATE.NAME'); $template_lang = self::get('TEMPLATE.LANG'); @@ -237,7 +237,7 @@ class Application { #=============================================================================== # Exit application with a custom message and status code #=============================================================================== - public static function exit(?string $message = NULL, int $code = 503): void { + public static function exit(?string $message = null, int $code = 503): void { http_response_code($code); exit($message); } diff --git a/core/namespace/Factory.php b/core/namespace/Factory.php index 779b890..e30895d 100644 --- a/core/namespace/Factory.php +++ b/core/namespace/Factory.php @@ -13,6 +13,6 @@ abstract class Factory implements FactoryInterface { # Gets an instance of a class from the runtime instance cache #=============================================================================== protected static function fetchInstance($identifier) { - return self::$storage[get_called_class()][$identifier] ?? FALSE; + return self::$storage[get_called_class()][$identifier] ?? false; } } diff --git a/core/namespace/HTTP.php b/core/namespace/HTTP.php index 9145539..90efa44 100644 --- a/core/namespace/HTTP.php +++ b/core/namespace/HTTP.php @@ -1,8 +1,8 @@ text = array_merge($this->text, $LANGUAGE ?? []); } @@ -34,7 +34,7 @@ class Language { #=============================================================================== # Return language string with included arguments #=============================================================================== - public function text($name, $arguments = NULL): string { + public function text($name, $arguments = null): string { if(!isset($this->text[$name])) { return "{{$name}}"; } diff --git a/core/namespace/Migrator.php b/core/namespace/Migrator.php index 7b8d263..607c137 100644 --- a/core/namespace/Migrator.php +++ b/core/namespace/Migrator.php @@ -17,7 +17,7 @@ class Migrator { $Statement = $Database->query('SELECT schema_version FROM migration'); # Explicitly check for FALSE, because result can be "0" - if(($this->version = $Statement->fetchColumn()) === FALSE) { + if(($this->version = $Statement->fetchColumn()) === false) { throw new Exception('The migration table does exist, but there is no row containing the currently used on-disk schema version!'); } diff --git a/core/namespace/ORM/Entity.php b/core/namespace/ORM/Entity.php index 61b9371..5462b54 100644 --- a/core/namespace/ORM/Entity.php +++ b/core/namespace/ORM/Entity.php @@ -13,7 +13,7 @@ abstract class Entity implements EntityInterface { # Get attribute #=============================================================================== public function get(string $attribute) { - return $this->{$attribute} ?? NULL; + return $this->{$attribute} ?? null; } #=============================================================================== diff --git a/core/namespace/ORM/Repositories/CategoryRepository.php b/core/namespace/ORM/Repositories/CategoryRepository.php index 7c7b3f9..657940c 100644 --- a/core/namespace/ORM/Repositories/CategoryRepository.php +++ b/core/namespace/ORM/Repositories/CategoryRepository.php @@ -47,7 +47,7 @@ class CategoryRepository extends Repository { # element. PHP >= 8 will throw a PDOException when the number of # bound variables doesn't matches the number of tokens ("?") in # the SQL query, which is the case here if $value is NULL. - is_null($value) ? NULL : [$value] + is_null($value) ? null : [$value] ); # TODO: Virtual column _depth shall not be fetched into the entity class @@ -128,7 +128,7 @@ class CategoryRepository extends Repository { $UpdateStatement = $this->Database->prepare($query); $UpdateStatement->execute([$_parent, $Entity->get('parent')]); break; - } else if($_parent === NULL) { + } else if($_parent === null) { break; } } diff --git a/core/namespace/ORM/Repository.php b/core/namespace/ORM/Repository.php index e7750cb..ca3690f 100644 --- a/core/namespace/ORM/Repository.php +++ b/core/namespace/ORM/Repository.php @@ -23,7 +23,7 @@ abstract class Repository { return $Entity; } - return NULL; + return null; } #=============================================================================== @@ -60,7 +60,7 @@ abstract class Repository { # Gets an entity from the runtime cache #=============================================================================== protected function fetchInstance($identifier) { - return $this->entities[$identifier] ?? FALSE; + return $this->entities[$identifier] ?? false; } #=============================================================================== @@ -93,7 +93,7 @@ abstract class Repository { return $Statement->execute($params); } - return FALSE; + return false; } #=========================================================================== @@ -115,7 +115,7 @@ abstract class Repository { return $Statement->execute($params); } - return FALSE; + return false; } #=========================================================================== @@ -199,7 +199,7 @@ abstract class Repository { if(!empty($filter)) { foreach($filter as $column => $value) { - if($value === NULL) { + if($value === null) { $wheres[] = "$column IS NULL"; } else { $wheres[] = "$column = ?"; diff --git a/core/namespace/ORM/RepositorySearch.php b/core/namespace/ORM/RepositorySearch.php index aac46ef..66f27ea 100644 --- a/core/namespace/ORM/RepositorySearch.php +++ b/core/namespace/ORM/RepositorySearch.php @@ -8,7 +8,7 @@ trait RepositorySearch { #=============================================================================== # Get entities based on search query #=============================================================================== - public function search(string $search, array $filter = [], int $limit = NULL, int $offset = 0): array { + public function search(string $search, array $filter = [], int $limit = null, int $offset = 0): array { if(strlen($filter['year'] ?? '') !== 0) { $extend[] = 'YEAR(time_insert) = ? AND'; $params[] = $filter['year']; @@ -24,12 +24,12 @@ trait RepositorySearch { $params[] = $filter['day']; } - if(is_numeric($filter['user'] ?? NULL)) { + if(is_numeric($filter['user'] ?? null)) { $extend[] = 'user = ? AND'; $params[] = $filter['user']; } - if(is_numeric($filter['category'] ?? NULL)) { + if(is_numeric($filter['category'] ?? null)) { $extend[] = 'category = ? AND'; $params[] = $filter['category']; } diff --git a/core/namespace/Parsers/ArgumentParser.php b/core/namespace/Parsers/ArgumentParser.php index ab32fe1..4ac3b9c 100644 --- a/core/namespace/Parsers/ArgumentParser.php +++ b/core/namespace/Parsers/ArgumentParser.php @@ -10,8 +10,8 @@ class ArgumentParser implements ParserInterface { foreach(explode('|', $text) as $delimiter) { $part = explode('=', $delimiter); - $argumentK = $part[0] ?? NULL; - $argumentV = $part[1] ?? TRUE; + $argumentK = $part[0] ?? null; + $argumentV = $part[1] ?? true; if(preg_match('#^[[:word:]]+$#', $argumentK)) { $arguments[strtoupper($argumentK)] = $argumentV; diff --git a/core/namespace/Parsers/MarkdownParser.php b/core/namespace/Parsers/MarkdownParser.php index 27a18ad..b9ebc15 100644 --- a/core/namespace/Parsers/MarkdownParser.php +++ b/core/namespace/Parsers/MarkdownParser.php @@ -10,7 +10,7 @@ class MarkdownParser implements ParserInterface { #=========================================================================== public function __construct() { $this->Parsedown = new Parsedown(); - $this->Parsedown->setUrlsLinked(FALSE); + $this->Parsedown->setUrlsLinked(false); } #=========================================================================== diff --git a/core/namespace/Router.php b/core/namespace/Router.php index 803a8e0..ffb3154 100644 --- a/core/namespace/Router.php +++ b/core/namespace/Router.php @@ -34,7 +34,7 @@ class Router { #=============================================================================== public static function execute($path) { $path = ltrim($path, '/'); - $route_found = FALSE; + $route_found = false; foreach(self::$routes as $route) { if($route['type'] === 'redirect') { @@ -50,13 +50,13 @@ class Router { # Remove the first element from matches which contains the whole string. array_shift($matches); - $route_found = TRUE; + $route_found = true; call_user_func_array($route['callback'], $matches); } } } - if($route_found === FALSE) { + if($route_found === false) { Application::error404(); } } diff --git a/core/namespace/Template/Template.php b/core/namespace/Template/Template.php index 25034a2..4967a7f 100644 --- a/core/namespace/Template/Template.php +++ b/core/namespace/Template/Template.php @@ -27,7 +27,7 @@ class Template { # Get parameter #=============================================================================== public function get($name) { - return $this->parameters[$name] ?? NULL; + return $this->parameters[$name] ?? null; } #=============================================================================== -- cgit v1.2.3