Closed
Description
My services.yml
services:
app.foo:
class: 'AppBundle\S\Foo'
abstract: true
calls:
- ['setBar', ['@app.bar']]
app.bar:
class: 'AppBundle\S\Bar'
app.quux:
class: 'AppBundle\S\Quux'
app.baz:
class: 'AppBundle\S\Baz'
autowire: true
parent: app.foo
# AppBundle/S/Foo.php
namespace AppBundle\S;
abstract class Foo
{
public function setBar(Bar $bar)
{
var_dump($bar);
}
}
# AppBundle/S/Bar.php
namespace AppBundle\S;
class Bar
{
}
# AppBundle/S/Baz.php
namespace AppBundle\S;
class Baz extends Foo
{
public function __construct(Quux $quux)
{
var_dump($quux);
}
}
# AppBundle/S/Quux.php
namespace AppBundle\S;
class Quux
{
}
When I ran $this->getContainer()->get('app.baz');
I got error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 1 passed to AppBundle\S\Baz::__construct() must be an instance of AppBundle\S\Quux, none given, called in /private/tmp/demo/var/cache/dev/appDevDebugProjectContainer.php on lin
e 315
/**
* Gets the 'app.baz' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return \AppBundle\S\Baz A AppBundle\S\Baz instance
*/
protected function getApp_BazService()
{
$this->services['app.baz'] = $instance = new \AppBundle\S\Baz();
$instance->setBar($this->get('app.bar'));
return $instance;
}