8000 [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

Closed
ro0NL wants to merge 1 commit intosymfony:masterfrom
ro0NL:di/iterator-to-array
Closed

[DI] Resolve iterator argument as plain array if required#22204
ro0NL wants to merge 1 commit intosymfony:masterfrom
ro0NL:di/iterator-to-array

Conversation

@ro0NL
Copy link
Copy Markdown
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
Copy Markdown
Member

👎 the config should be fixed instead.

@ro0NL
Copy link
Copy Markdown
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