Skip to content

[DependencyInjection] DefinitionDecorator is broken, no tests. #5419

Closed
@HelloGrayson

Description

@HelloGrayson

When configuring the container using the DefinitionDecorator as described in this guide the expected outcome is... unexpected.

The following example illustrates the problem. $test->foo should have the value foo instead of null.

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

abstract class TestAbstract
{
    public $foo;

    public function __construct($foo = null)
    {
        $this->foo = $foo;
    }
}

class Test extends TestAbstract
{
}

$container = new ContainerBuilder();

$container->register('test_abstract')
    ->addArgument('foo')
    ->setAbstract(true);

$container->setDefinition('test', new DefinitionDecorator('test_abstract'))
    ->setClass('Test');

$test = $container->get('test');
var_dump($test->foo); // is null...

Looks like there aren't any tests for this functionality.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions