Skip to content

Standardize definition handling in nested definitions/arrays #498

@mnapoli

Description

@mnapoli

Currently there are inconsistencies when definitions are at the root of the array or nested in:

The goal would be to make all those behaviors identical (less surprises). Since the container is now compiled performances should not be a problem.

example of test case to reuse:

    /**
     * @dataProvider provideContainer
     */
    public function test_nested_array_with_nested_definitions_in_sub_definition(ContainerBuilder $builder)
    {
        $builder->addDefinitions([
            SimpleClass::class => create()
                ->property(
                    'dependency',
                    [
                        \DI\env('PHP_DI_DO_NOT_DEFINE_THIS', 'env'),
                        \DI\create('stdClass'),
                    ]
                ),
        ]);
        $container = $builder->build();

        $object = $container->get(SimpleClass::class);

        $this->assertEquals('env', $object->dependency[0]);
        $this->assertEquals(new \stdClass, $object->dependency[1]);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions