-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Allow imports in string format for YAML #22176
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
Conversation
@@ -181,7 +181,9 @@ private function parseImports(array $content, $file) | |||
$defaultDirectory = dirname($file); | |||
foreach ($content['imports'] as $import) { | |||
if (!is_array($import)) { | |||
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); | |||
$import = array('resource' => $import); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only strings should be allowed to be rewritten that way, not any non-array value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really care? Whatever the input is; it crashes like before.
imports:
- { resource: { breakit: config.yml } }
Warning: strlen() expects parameter 1 to be string, array given
Which actually comes from FileLoader::glob()
. AFAIK the api describes type mixed
for resources. Hence i think we should just pass here... and fix the glob issue of course ^^
@@ -82,6 +82,10 @@ public function getLocator() | |||
*/ | |||
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) | |||
{ | |||
if (!is_string($resource)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny change introduced after #21635
Tests added. Build failures unrelated. |
Rebased. Would love to see this in 3.4 👼 (same trend as we did with |
Thank you @ro0NL. |
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Allow imports in string format for YAML | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> I see no real reasons why this shouldnt be allowed.. Before ```yml imports: - { resource: config.yml } ``` After ```yml imports: - config.yml ``` Commits ------- 632e934 [DI] Allow imports in string format for YAML
I see no real reasons why this shouldnt be allowed..
Before
After