Closed llaville closed 1 year ago
I've one more regression to fix before to merge.
When a YAML config file identify a path
and console input identify also another path
value, current code use YAML content !
And it should be override
PS: fixed by commit 5739b2f034fe920d0d451b8ad22fef8e746e90a1
Issue #167 was fixed by this PR
@overtrue Finally after merging this PR to codebase, I've noticed some regressions. This is the reason why I'll patch with this better code
diff --git a/src/Configuration/ConfigResolver.php b/src/Configuration/ConfigResolver.php
index 5302329..7204d60 100644
--- a/src/Configuration/ConfigResolver.php
+++ b/src/Configuration/ConfigResolver.php
@@ -11,6 +11,7 @@ use Symfony\Component\Yaml\Yaml;
use Throwable;
use function array_keys;
+use function array_replace_recursive;
use function count;
use function dirname;
use function getcwd;
@@ -92,9 +93,7 @@ final class ConfigResolver
{
if (!empty($this->options[self::OPTION_CONFIG_FILE])) {
$conf = $this->loadConfiguration($this->options[self::OPTION_CONFIG_FILE]);
- if ($conf[self::OPTION_PATH] !== $this->options[self::OPTION_PATH]) {
- $conf[self::OPTION_PATH] = $this->options[self::OPTION_PATH];
- }
+ $conf = array_replace_recursive($conf, $this->options);
$config = $this->getOptions()->resolve($conf);
} else {
$config = $this->options;
@@ -131,6 +130,9 @@ final class ConfigResolver
try {
$configuration = Yaml::parseFile($path);
if (is_array($configuration)) {
+ if (!is_array($configuration[self::OPTION_PATH])) {
+ $configuration[self::OPTION_PATH] = [$configuration[self::OPTION_PATH]];
+ }
return $configuration;
}
$this->exceptions[] = new ParseException(
Explains Options/Arguments (for path) given on command line should have a highter importance than those provided by a YAML config file !
To solve issue #163