diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d842f..32e788d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ### Changed - Added GitHub build action for PHP 8.4 - Updated GitHub build `action/checkout` and `action/cache` +- Code syntax and comment cleanup ### Fixed - Implicit null values in `SymfonyConfigFilter` and `YamlFileLoader` classes - `IniFileLoader` behavior (not sure why the tests _ever_ passed) diff --git a/src/ConfigFactory.php b/src/ConfigFactory.php index d249198..635c5c6 100644 --- a/src/ConfigFactory.php +++ b/src/ConfigFactory.php @@ -89,7 +89,7 @@ public static function loadFiles(iterable $files): ConfigValues } /** - * Build configuration by reading a single directory of files (non-recursive; ignores sub-directories) + * Build configuration by reading a single directory of files (non-recursive; ignores subdirectories) * * @param string $configDirectory * @param array $defaults @@ -109,10 +109,10 @@ public static function loadSingleDirectory(string $configDirectory, array $defau */ public static function loadPath(string $configPath = '', array $defaults = []): ConfigValues { - // If path, use default behavior.. + // If path, use default behavior... if (is_dir($configPath)) { $pathValues = (new FolderLoader($configPath))->load(); - } elseif (is_file($configPath)) { // Elseif if file, then just load that single file... + } elseif (is_file($configPath)) { // Elseif file, then just load that single file... $pathValues = (new FileLoader($configPath))->load(); } elseif ($configPath === '') { // Else, no path provided, so empty values $pathValues = new ConfigValues([]); @@ -129,7 +129,7 @@ public static function loadPath(string $configPath = '', array $defaults = []): * * @param string $prefix Specify a prefix, and only environment variables with this prefix will be read * (e.g. "MYAPP_" means that this will only read env vars starting with - * "MYAPP_")' Values will be + * "MYAPP_") * @param string $delimiter Split variable names on this string into a nested array. (e.g. "MYSQL_HOST" * would become the key, "MYSQL.HOST" (empty string to not delimit) * @param bool $toLower Convert all keys to lower-case diff --git a/src/ConfigValues.php b/src/ConfigValues.php index eb8bfbb..22ff6f6 100644 --- a/src/ConfigValues.php +++ b/src/ConfigValues.php @@ -274,7 +274,7 @@ public function valid(string $path): bool * * Flattens the structure and implodes paths * - * @return iterable|array|Traversable|array + * @return iterable|array|Traversable */ #[\ReturnTypeWillChange] public function getIterator(): iterable diff --git a/src/Loader/EnvLoader.php b/src/Loader/EnvLoader.php index aaa9469..5936c4b 100644 --- a/src/Loader/EnvLoader.php +++ b/src/Loader/EnvLoader.php @@ -54,7 +54,7 @@ final class EnvLoader implements ConfigLoaderInterface * * @param string $prefix Specify a prefix, and only environment variables with this prefix will be read * (e.g. "MYAPP_" means that this will only read env vars starting with - * "MYAPP_")' Values will be + * "MYAPP_") * @param string $delimiter Split variable names on this string into a nested array. (e.g. "MYSQL_HOST" * would become the key, "MYSQL.HOST" (empty string to not delimit) * @param bool $toLower Convert all keys to lower-case @@ -63,7 +63,7 @@ final class EnvLoader implements ConfigLoaderInterface public static function loadUsingPrefix(string $prefix, string $delimiter = '', bool $toLower = false): ConfigValues { $prefix = preg_quote($prefix); - $values = (new EnvLoader("/^{$prefix}/", $delimiter, $toLower))->load(); + $values = (new EnvLoader("/^$prefix/", $delimiter, $toLower))->load(); return $delimiter ? (new ExtractTopLevelItemsFilter($toLower ? strtolower($prefix) : $prefix, $delimiter))->__invoke($values) diff --git a/src/Loader/FileLoader.php b/src/Loader/FileLoader.php index 3e47ad8..79fe2bb 100644 --- a/src/Loader/FileLoader.php +++ b/src/Loader/FileLoader.php @@ -97,7 +97,7 @@ public function load(): ConfigValues sprintf( "Error parsing file (no loader for extension '%s'): %s", $file->getExtension(), - (string) $file + $file ) ); } diff --git a/src/Loader/PhpFileLoader.php b/src/Loader/PhpFileLoader.php index 7f4bfde..6e1d8ac 100644 --- a/src/Loader/PhpFileLoader.php +++ b/src/Loader/PhpFileLoader.php @@ -52,7 +52,7 @@ public function __construct(string $filePath) */ public function load(): ConfigValues { - // If file is not readable for any reason (permissions, etc), throw an exception + // If file is not readable for any reason (permissions, etc.), throw an exception if (! is_readable($this->filePath)) { throw new ConfigLoaderException("Error reading config from file (check permissions?): " . $this->filePath); } diff --git a/src/Util/ArrayUtils.php b/src/Util/ArrayUtils.php index 8f4a251..0746404 100644 --- a/src/Util/ArrayUtils.php +++ b/src/Util/ArrayUtils.php @@ -64,7 +64,7 @@ public static function merge(array $arr1, array $arr2): array { foreach ($arr2 as $key => $value) { if (array_key_exists($key, $arr1) && is_array($value) && is_array($arr1[$key])) { - $arr1[$key] = static::merge($arr1[$key], $arr2[$key]); + $arr1[$key] = static::merge($arr1[$key], $value); } else { $arr1[$key] = $value; } diff --git a/src/Util/LocalDistFileIterator.php b/src/Util/LocalDistFileIterator.php index c569b3f..54b4b93 100644 --- a/src/Util/LocalDistFileIterator.php +++ b/src/Util/LocalDistFileIterator.php @@ -28,9 +28,9 @@ * * Iterates over files in the following order: * - * *.dist.EXT ('.dist' is configurable) + * *.dist.EXT (.dist is configurable) * *.EXT - * *.local.EXT ('.local' is configurable) + * *.local.EXT (.local is configurable) * * @author Casey McLaughlin */ @@ -68,7 +68,7 @@ public function __construct(iterable $fileIterator, string $localSuffix = '.loca * @return Generator */ #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): Generator { $localFiles = []; $normalFiles = [];