From: Roland Häder Date: Wed, 20 Jul 2022 16:22:06 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d693570a612eaadcd1d31875fdd2473737ebcead;p=core.git Continued: - added some parameter checks --- diff --git a/framework/config/class_FrameworkConfiguration.php b/framework/config/class_FrameworkConfiguration.php index d5d400d0..199b15b8 100644 --- a/framework/config/class_FrameworkConfiguration.php +++ b/framework/config/class_FrameworkConfiguration.php @@ -86,6 +86,7 @@ class FrameworkConfiguration implements Registerable { */ public function isConfigurationEntrySet (string $configKey) { // Is it null? + //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey); if (empty($configKey)) { // Entry is empty throw new InvalidArgumentException('Parameter "configKey" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); @@ -95,6 +96,7 @@ class FrameworkConfiguration implements Registerable { $isset = ((isset(self::$configData[$configKey])) || (array_key_exists($configKey, self::$configData))); // Return the result + //* NOISY-DEBUG: */ printf('[%s:%d]: isset=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval($isset)); return $isset; } diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 15a73612..ffb4c436 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -341,8 +341,15 @@ final class ClassLoader { * * @param $relativePath Relative path to test classes * @return void + * @throws InvalidArgumentException If a parameter is invalid */ public static function registerTestsPath (string $relativePath) { + // Validate parameter + if (empty($relativePath)) { + // Should not be empty + throw new InvalidArgumentException('Parameter "relativePath" is empty'); + } + // "Register" it //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath); self::$testPaths[$relativePath] = $relativePath; @@ -431,11 +438,15 @@ final class ClassLoader { * @param $basePath The relative base path to 'framework_base_path' constant for all classes * @param $ignoreList An optional list (array forced) of directory and file names which shall be ignored * @return void + * @throws InvalidArgumentException If a parameter is invalid */ protected function scanClassPath (string $basePath, array $ignoreList = [] ) { // Is a list has been restored from cache, don't read it again //* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s,ignoreList()=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $basePath, count($ignoreList)); - if ($this->listCached === true) { + if (empty($basePath)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "basePath" is empty'); + } elseif ($this->listCached === true) { // Abort here //* NOISY-DEBUG: */ printf('[%s:%d] this->listCache=true - EXIT!' . PHP_EOL, __METHOD__, __LINE__); return;