From bb6644d1b92c5e37b84cb82218083c77ec66b3df Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Wed, 22 Feb 2023 09:27:34 +0100 Subject: [PATCH] Correct some minor warnings and delete useless file --- Source/Config/Autoload.php | 12 ++++++------ Source/Config/Clean.php | 8 ++++---- Source/Config/Exception/a | 0 Source/Config/SplClassLoader.php | 10 +++++----- Source/Config/Validate.php | 30 +++++++++++++++--------------- 5 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 Source/Config/Exception/a diff --git a/Source/Config/Autoload.php b/Source/Config/Autoload.php index 72c9ecb..4fdb894 100644 --- a/Source/Config/Autoload.php +++ b/Source/Config/Autoload.php @@ -4,33 +4,33 @@ class Autoload { private static $instance = null; - public static function charger() + public static function charger(): void { if (null !== self::$instance) { - throw RuntimeException(sprintf('%s is already started', __CLASS__)); + throw new RuntimeException(sprintf('%s is already started', __CLASS__)); } self::$instance = new self(); if (!spl_autoload_register(array(self::$instance, 'autoloader'), false)) { - throw RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__)); + throw new RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__)); } } - public static function shutDown() + public static function shutDown(): void { if (null !== self::$instance) { if (!spl_autoload_unregister(array(self::$instance, 'autoloader'))) { - throw RuntimeException('Could not stop the autoload'); + throw new RuntimeException('Could not stop the autoload'); } self::$instance = null; } } - private static function autoloader($className) + private static function autoloader($className): void { $folder = "./"; $className = ltrim($className, '\\'); diff --git a/Source/Config/Clean.php b/Source/Config/Clean.php index afea0c8..7d736bc 100644 --- a/Source/Config/Clean.php +++ b/Source/Config/Clean.php @@ -11,7 +11,7 @@ class Clean * @return string La chaîne nettoyée */ - static function simpleString($string): string + static function simpleString(string $string): string { $string = trim($string); $string = strip_tags($string); @@ -21,11 +21,11 @@ class Clean /** * Cette fonction prend une chaîne de caractères en entrée et retourne une version nettoyée de cette chaîne. * Elle supprime les espaces de début et de fin, ainsi que toutes les balises HTML, et encode les caractères spéciaux. - * @param string $string La chaîne à nettoyer + * @param $email * @return string La chaîne nettoyée */ - static function email($email) + static function email($email): string { $email = self::simpleString($email); return filter_var($email, FILTER_SANITIZE_EMAIL); @@ -38,7 +38,7 @@ class Clean * @return int Le nombre entier formaté */ - static function int($int) + static function int(int $int): int { return filter_var($int, FILTER_SANITIZE_NUMBER_INT); } diff --git a/Source/Config/Exception/a b/Source/Config/Exception/a deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Config/SplClassLoader.php b/Source/Config/SplClassLoader.php index 045b762..668ae98 100644 --- a/Source/Config/SplClassLoader.php +++ b/Source/Config/SplClassLoader.php @@ -29,7 +29,7 @@ * $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine'); * $classLoader->register(); * - * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @license http://www.opensource.org/licenses/mit-license.html MIT License * @author Jonathan H. Wage * @author Roman S. Borschel * @author Matthew Weier O'Phinney @@ -38,10 +38,10 @@ */ class SplClassLoader { - private $fileExtension = '.php'; - private $namespace; - private $includePath; - private $namespaceSeparator = '\\'; + private string $fileExtension = '.php'; + private ?string $namespace; + private ?string $includePath; + private string $namespaceSeparator = '\\'; /** * Creates a new SplClassLoader that loads classes of the diff --git a/Source/Config/Validate.php b/Source/Config/Validate.php index 99c7a54..b359ee4 100644 --- a/Source/Config/Validate.php +++ b/Source/Config/Validate.php @@ -11,7 +11,7 @@ class Validate * @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon. */ - static function email (String $email) + static function email (String $email): bool { global $emailMaxLength; if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength){ @@ -28,7 +28,7 @@ class Validate * @return bool Vrai si le pseudo est valide, faux sinon. */ - static function pseudo($pseudo) : bool + static function pseudo(string $pseudo) : bool { global $pseudoMaxLength; if(strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){ @@ -45,7 +45,7 @@ class Validate * @return bool Vrai si le mot de passe est valide, faux sinon. */ - static function password($password) : bool + static function password(string $password) : bool { global $passwordMaxLength; if(strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password)){ @@ -57,14 +57,14 @@ class Validate /** * Vérifie si le mot-clé est valide. * - * @param string $keyword Le mot-clé à vérifier. + * @param string $keyword Le mot-clé a vérifié. * @return bool Vrai si le mot-clé est valide, faux sinon. */ - static function keyWord($keyword) : bool + static function keyWord(string $keyword) : bool { global $keyWordMaxLength; - if (isset($keyword) && strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3) + if (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3) return true; else return false; } @@ -72,14 +72,14 @@ class Validate /** * Vérifie si le titre est valide. * - * @param string $title Le titre à vérifier. + * @param string $title Le titre a vérifié. * @return bool Vrai si le titre est valide, faux sinon. */ - static function title($title) : bool + static function title(string $title) : bool { global $titleMaxLength; - if (isset($title) && strlen($title) <= $titleMaxLength && strlen($title) >= 3) + if (strlen($title) <= $titleMaxLength && strlen($title) >= 3) return true; else return false; } @@ -87,14 +87,14 @@ class Validate /** * Vérifie si le type est valide. * - * @param string $type Le type à vérifier. + * @param string $type Le type a vérifié. * @return bool Vrai si le type est valide, faux sinon. */ - static function type($type) : bool + static function type(string $type) : bool { global $typeMaxLength; - if (isset($type) && strlen($type) <= $typeMaxLength && strlen($type) >=3) + if (strlen($type) <= $typeMaxLength && strlen($type) >=3) return true; else return false; } @@ -102,13 +102,13 @@ class Validate /** * Vérifie si la réponse est valide. * - * @param string $response La réponse à vérifier. + * @param string $response La réponse a vérifié. * @return bool Vrai si la réponse est valide, faux sinon. */ - static function response($response) : bool{ + static function response(string $response) : bool{ global $responseMaxLength; - if(isset($response) && strlen($response) <= $responseMaxLength) + if(strlen($response) <= $responseMaxLength) return true; else return false; }