Skip to content

Commit

Permalink
Code syntax and comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyamcl committed Dec 7, 2024
1 parent 794b0db commit 4c3cbc4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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([]);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/EnvLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function load(): ConfigValues
sprintf(
"Error parsing file (no loader for extension '%s'): %s",
$file->getExtension(),
(string) $file
$file
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/PhpFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Util/LocalDistFileIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <caseyamcl@gmail.com>
*/
Expand Down Expand Up @@ -68,7 +68,7 @@ public function __construct(iterable $fileIterator, string $localSuffix = '.loca
* @return Generator<int,SplFileInfo>
*/
#[\ReturnTypeWillChange]
public function getIterator()
public function getIterator(): Generator
{
$localFiles = [];
$normalFiles = [];
Expand Down

0 comments on commit 4c3cbc4

Please sign in to comment.