Skip to content

Throw an exception if a ContainerBuilder is modified *after* building the container #421

@mnapoli

Description

@mnapoli

The goal is to detect errors sooner when users will do something like this:

$containerBuilder->addDefinitions(...);

$container = $containerBuilder->build();

$containerBuilder->addDefinitions([
    'foo' => 'bar',
]);

$container->get('foo'); // Exception

Definitions (or anything actually) added after the container was created is ignored, but it sometimes can be not obvious.

By "locking" the builder after the container is created (throwing an exception on all modifications) could help.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions