{"action":"closed","issue":{"url":"https://api.github.com/repos/nette/di/issues/94","repository_url":"https://api.github.com/repos/nette/di","labels_url":"https://api.github.com/repos/nette/di/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/nette/di/issues/94/comments","events_url":"https://api.github.com/repos/nette/di/issues/94/events","html_url":"https://github.com/nette/di/issues/94","id":131744404,"number":94,"title":"Broken InjectExtension with removed definition","user":{"login":"MartinSadovy","id":179039,"avatar_url":"https://avatars.githubusercontent.com/u/179039?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinSadovy","html_url":"https://github.com/MartinSadovy","followers_url":"https://api.github.com/users/MartinSadovy/followers","following_url":"https://api.github.com/users/MartinSadovy/following{/other_user}","gists_url":"https://api.github.com/users/MartinSadovy/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinSadovy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinSadovy/subscriptions","organizations_url":"https://api.github.com/users/MartinSadovy/orgs","repos_url":"https://api.github.com/users/MartinSadovy/repos","events_url":"https://api.github.com/users/MartinSadovy/events{/privacy}","received_events_url":"https://api.github.com/users/MartinSadovy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-05T20:14:06Z","updated_at":"2016-02-08T22:56:45Z","closed_at":"2016-02-08T22:56:45Z","body":"#71 #72 broke InjectExtension. When [another extension override definition with own definition](https://github.com/Kdyby/Doctrine/blob/master/src/Kdyby/Doctrine/DI/OrmExtension.php#L741), it removes class from $classes, but ->addDefinition does not add new.\r\n\r\ncertain description (see link):\r\n1) $classes is prepared by https://github.com/nette/di/blob/master/src/DI/Compiler.php#L202\r\n2) OrmExtension override definition https://github.com/Kdyby/Doctrine/blob/master/src/Kdyby/Doctrine/DI/OrmExtension.php#L741 (beforeCompile) - remove $classes https://github.com/nette/di/blob/master/src/DI/ContainerBuilder.php#L81\r\n3) Next extension (InjectExtension) want to service by class in beforeCompile https://github.com/nette/di/blob/master/src/DI/Extensions/InjectExtension.php#L126 (btw. see second param which missing)\r\n4) there is null https://github.com/nette/di/blob/master/src/DI/ContainerBuilder.php#L210\r\n\r\ntestcase:\r\n```\r\n$builder = new DI\\ContainerBuilder;\r\n\r\n$builder->addDefinition('one')\r\n\t->setClass('stdClass');\r\n\r\n$builder->prepareClassList();\r\n\r\n$builder->removeDefinition('one');\r\n$builder->addDefinition('one')\r\n\t->setClass('stdClass');\r\n\r\nAssert::count(1, $builder->findByType('stdClass')); // Failed: Count 0 should be 1\r\nAssert::same('one', $builder->getByType('stdClass')); // Failed: NULL should be 'one'\r\n```\r\n\r\n"}}