# Check if a service was removed from the container at compile time #312

Merged
merged 1 commit into from Feb 4, 2019

## Conversation

Projects
None yet
4 participants
Contributor

### aschempp commented Feb 1, 2019

 I realized there's actually a way to check if a service was removed at compile time, so we can check for that instead of assuming we need to create an instance if there are no constructor arguments. Also updated the error message to match Symfony.
 Check if a service was removed from the container at compile time 
 1b2c8d0 

Member

 Neat!

### leofeyer reviewed Feb 1, 2019

#### aschempp Feb 2, 2019

Author Contributor

No, we require 3.4 minimum.

#### leofeyer Feb 2, 2019

Member

What has that to do with it? We are checking for method existence in other places, too, e.g. here: https://github.com/contao/contao/blob/4.4/core-bundle/src/Doctrine/Schema/DcaSchemaProvider.php#L317

#### ausi Feb 2, 2019

Member

IMO the instanceof check is correct here. The existence of getRemovedIds() doesn’t guarantee that it works as we expect it, but the BC promise of Symfony should guarantee that the Container class works as expected.

#### aschempp Feb 4, 2019

Author Contributor

We're checking for the method existence because there can be differences in our dependencies. Not so in the case, the method must always be there if that class is implemented (which we actually know it is, but the interface does not guarantee that).

### leofeyer merged commit 4983343 into contao:4.7 Feb 4, 2019 2 checks passed

#### 2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
coverage/coveralls Coverage remained the same at 88.499%
Details
Member

### leofeyer commented Feb 4, 2019

 Thank you @aschempp.