Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces new component ConfigResolver #166

Merged
merged 8 commits into from
Dec 22, 2022
Merged

Introduces new component ConfigResolver #166

merged 8 commits into from
Dec 22, 2022

Conversation

llaville
Copy link
Collaborator

To solve issue #163

@llaville llaville requested a review from overtrue December 21, 2022 13:59
@llaville
Copy link
Collaborator Author

llaville commented Dec 21, 2022

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 5739b2f

@llaville
Copy link
Collaborator Author

Issue #167 was fixed by this PR

@llaville llaville merged commit 6e820ea into 8.0 Dec 22, 2022
@delete-merged-branch delete-merged-branch bot deleted the fix-163 branch December 22, 2022 12:12
@llaville
Copy link
Collaborator Author

@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 !

llaville added a commit that referenced this pull request Dec 22, 2022
llaville added a commit that referenced this pull request Dec 22, 2022
llaville added a commit that referenced this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants