8000 [DI] Allow imports in string format for YAML by ro0NL · Pull Request #22176 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 1 commit into from
Jul 11, 2017
Merged

[DI] Allow imports in string format for YAML #22176

merged 1 commit into from
Jul 11, 2017

Conversation

ro0NL
Copy link
Contributor
@ro0NL ro0NL commented Mar 27, 2017
Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

I see no real reasons why this shouldnt be allowed..

Before

imports:
    - { resource: config.yml }

After

imports:
    - config.yml

@@ -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);
Copy link
Member

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

Copy link
Contributor Author

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)) {
Copy link
Contributor Author

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

@nicolas-grekas nicolas-grekas added this to the 3.x milestone Mar 28, 2017
@ro0NL
Copy link
Contributor Author
ro0NL commented Mar 28, 2017

Tests added. Build failures unrelated.

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 8, 2017

Rebased. Would love to see this in 3.4 👼 (same trend as we did with tags: [tag, tagN]

@ro0NL ro0NL changed the base branch from master to 3.4 July 8, 2017 16:29
@fabpot
Copy link
Member
fabpot commented Jul 11, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit 632e934 into symfony:3.4 Jul 11, 2017
fabpot added a commit that referenced this pull request Jul 11, 2017
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
@ro0NL ro0NL deleted the di/simplify-imports branch July 12, 2017 11:22
This was referenced Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0