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 78d86f8 commit 9f8358e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Expand Up @@ -44,7 +44,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 @@ -87,6 +87,7 @@ public function getProxyCandidates()
$definitions = array(
array(new Definition(__CLASS__), true),
array(new Definition('stdClass'), true),
array(new Definition('Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface'), true),
array(new Definition(uniqid('foo', true)), false),
array(new Definition(), false),
);
Expand Down

0 comments on commit 9f8358e

Please sign in to comment.