Skip to content

Commit

Permalink
[Bridge\ProxyManager] isProxyCandidate() does not take into account i…
Browse files Browse the repository at this point in the history
…nterfaces

When using factories it's common best practice to use interface as class name, especially in cases
where you know impl can differ. Before this fix ProxyManager did not allow these to be lazy.

In our case this has lead several to hard to debug issues on classes we need to mark as lazyi
and often a need to add lazy on decorators if there are any or other workarounds.
As we have had this issue, and still have on both 2.8 and 3.4 this is opened against 2.8.
  • Loading branch information
andrerom committed May 20, 2019
1 parent 365a390 commit e3739b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Expand Up @@ -47,7 +47,7 @@ public function __construct($salt = '')
*/
public function isProxyCandidate(Definition $definition)
{
return $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class);
return $definition->isLazy() && ($class = $definition->getClass()) && (class_exists($class) || interface_exists($class));
}

/**
Expand Down
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

/**
* Tests for {@see \Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper}.
Expand Down Expand Up @@ -137,6 +138,7 @@ public function getProxyCandidates()
$definitions = [
[new Definition(__CLASS__), true],
[new Definition('stdClass'), true],
[new Definition(DumperInterface::class), true],
[new Definition(uniqid('foo', true)), false],
[new Definition(), false],
];
Expand Down

0 comments on commit e3739b1

Please sign in to comment.