10000 [DI] Resolve iterator argument as plain array if required by ro0NL · Pull Request #22204 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Resolve iterator argument as plain array if required #22204

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

Closed
wants to merge 1 commit into from
Closed

[DI] Resolve iterator argument as plain array if required #22204

wants to merge 1 commit into from

Conversation

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

Given

class Foo {
    private $bars;
    public function __construct(array $bars) {
        $this->bars = $bars;
    }
}
services:
    a: { class: stdClass }
    b: { class: stdClass }
    Foo: [!iterator ['@a', '@b']]
dump($this->get(Foo::class));

Before

Catchable Fatal Error: Argument 1 passed to AppBundle\Foo::__construct() must be of the type array, object given

After

Foo {#223 ▼
  -bars: array:2 [▼
    0 => {#224}
    1 => {#222}
  ]
}

@nicolas-grekas
Copy link
Member

👎 the config should be fixed instead.

@ro0NL
Copy link
Contributor Author
ro0NL commented Mar 28, 2017

on 2nd thought this should probably just be built-in with #22200

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.

3 participants
0