Skip to content

Conversation

alafon
Copy link
Contributor

@alafon alafon commented Nov 17, 2016

Issue $container->get() should not be called during compiler passes to avoid issues where a resolver service (for instance), implements ContainerAwareInterface and for which a service is not fully yet created.

This fix uses $container->findDefinition() instead and checks if the class (string) is a sub class of the interface.

Copy link
Contributor

@ooflorent ooflorent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed solution is neat! There are a things to change but once committed, this PR could be merged. Nice work!


if ($solution instanceof ContainerAwareInterface) {
$definition = $container->findDefinition($solutionID);
if (is_subclass_of($definition->getClass(), 'Symfony\Component\DependencyInjection\ContainerAwareInterface')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. Using the ::class keywords would be better.

if (is_subclass_of($definition->getClass(), ContainerAwareInterface::class)) {

}
}

class FakeCompilerPass implements CompilerPassInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create separate files for each class to respect psr4 please, thanks for the work :)

Copy link
Contributor

@mcg-web mcg-web left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcg-web mcg-web dismissed ooflorent’s stale review November 18, 2016 09:44

::class not compatible with php 5.4...

@mcg-web mcg-web merged commit bc3395d into overblog:master Nov 18, 2016
@alafon alafon deleted the fix-container-pass branch December 20, 2016 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants