diff options
Diffstat (limited to 'core/namespace')
-rw-r--r-- | core/namespace/Application.php | 12 | ||||
-rw-r--r-- | core/namespace/Factory.php | 2 | ||||
-rw-r--r-- | core/namespace/HTTP.php | 38 | ||||
-rw-r--r-- | core/namespace/Language.php | 4 | ||||
-rw-r--r-- | core/namespace/Migrator.php | 2 | ||||
-rw-r--r-- | core/namespace/ORM/Entity.php | 2 | ||||
-rw-r--r-- | core/namespace/ORM/Repositories/CategoryRepository.php | 4 | ||||
-rw-r--r-- | core/namespace/ORM/Repository.php | 10 | ||||
-rw-r--r-- | core/namespace/ORM/RepositorySearch.php | 6 | ||||
-rw-r--r-- | core/namespace/Parsers/ArgumentParser.php | 4 | ||||
-rw-r--r-- | core/namespace/Parsers/MarkdownParser.php | 2 | ||||
-rw-r--r-- | core/namespace/Router.php | 6 | ||||
-rw-r--r-- | core/namespace/Template/Template.php | 2 |
13 files changed, 47 insertions, 47 deletions
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 @@ <?php class HTTP { - private static $GET = NULL; - private static $POST = NULL; - private static $FILE = NULL; + private static $GET = null; + private static $POST = null; + private static $FILE = null; #=============================================================================== # HTTP protocol versions @@ -76,7 +76,7 @@ class HTTP { #=============================================================================== # Initialize $GET, $POST and $FILE #=============================================================================== - public static function init($GET, $POST, $FILE, $removeArrays = FALSE, $trimValues = TRUE) { + public static function init($GET, $POST, $FILE, $removeArrays = false, $trimValues = true) { self::$GET = $GET; self::$POST = $POST; self::$FILE = $FILE; @@ -86,8 +86,8 @@ class HTTP { self::$POST = self::removeArrayValues(self::$POST); } - self::$GET = ($trimValues === TRUE ? self::trim(self::$GET) : self::$GET ); - self::$POST = ($trimValues === TRUE ? self::trim(self::$POST) : self::$POST); + self::$GET = ($trimValues === true ? self::trim(self::$GET) : self::$GET ); + self::$POST = ($trimValues === true ? self::trim(self::$POST) : self::$POST); } #=============================================================================== @@ -116,38 +116,38 @@ class HTTP { private static function issetData($data, $arguments): bool { foreach($arguments as $key) { if(is_array($key)) { - if(!isset($data[key($key)]) OR $data[key($key)] !== $key[key($key)]) { - return FALSE; + if(!isset($data[key($key)]) or $data[key($key)] !== $key[key($key)]) { + return false; } } - else if(!isset($data[$key]) OR !is_string($data[$key])) { - return FALSE; + else if(!isset($data[$key]) or !is_string($data[$key])) { + return false; } } - return TRUE; + return true; } #=============================================================================== # Return GET value #=============================================================================== public static function GET($parameter) { - return self::$GET[$parameter] ?? NULL; + return self::$GET[$parameter] ?? null; } #=============================================================================== # Return POST value #=============================================================================== public static function POST($parameter) { - return self::$POST[$parameter] ?? NULL; + return self::$POST[$parameter] ?? null; } #=============================================================================== # Return FILE value #=============================================================================== public static function FILE($parameter) { - return self::$FILE[$parameter] ?? NULL; + return self::$FILE[$parameter] ?? null; } #=============================================================================== @@ -182,13 +182,13 @@ class HTTP { # Get cookie #=============================================================================== public static function getCookie($name) { - return $_COOKIE[$name] ?? NULL; + return $_COOKIE[$name] ?? null; } #=============================================================================== # Return HTTP request method or check if request method equals with $method #=============================================================================== - public static function requestMethod($method = NULL) { + public static function requestMethod($method = null) { if(!empty($method)) { return ($_SERVER['REQUEST_METHOD'] === $method); } @@ -200,7 +200,7 @@ class HTTP { # Return REQUEST_URI #=============================================================================== public static function requestURI() { - return $_SERVER['REQUEST_URI'] ?? FALSE; + return $_SERVER['REQUEST_URI'] ?? false; } #=============================================================================== @@ -213,10 +213,10 @@ class HTTP { #=============================================================================== # Sends a HTTP redirect to the client #=============================================================================== - public static function redirect($location, $code = 303, $exit = TRUE) { + public static function redirect($location, $code = 303, $exit = true) { http_response_code($code); self::sendHeader("Location: {$location}"); - $exit AND exit(); + $exit and exit(); } #=============================================================================== diff --git a/core/namespace/Language.php b/core/namespace/Language.php index a2facb0..804f3d5 100644 --- a/core/namespace/Language.php +++ b/core/namespace/Language.php @@ -18,7 +18,7 @@ class Language { # Load another language file #=============================================================================== public function load($filename) { - if(file_exists($filename) AND is_readable($filename)) { + if(file_exists($filename) and is_readable($filename)) { require $filename; $this->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; } #=============================================================================== |