Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mnapoli opened this issue Jun 2, 2016 · 0 comments
Assignees
Milestone

Comments

@mnapoli
Copy link
Member

@mnapoli mnapoli commented Jun 2, 2016

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.

@mnapoli mnapoli added the enhancement label Jun 2, 2016
@mnapoli mnapoli added the easy-pick label Jun 12, 2016
mnapoli added a commit that referenced this issue Aug 23, 2016
The goal is to detect errors sooner when users will do something like this:

```php
$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.
@mnapoli mnapoli added this to the 5.4 milestone Aug 23, 2016
@mnapoli mnapoli self-assigned this Aug 23, 2016
@mnapoli mnapoli closed this in #436 Aug 23, 2016
mnapoli added a commit that referenced this issue Aug 23, 2016
#421 Lock the ContainerBuilder once the container has been built
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.