[Bridge\ProxyManager] isProxyCandidate() does not take into account interfaces
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.
This commit is contained in:
parent
365a390e6e
commit
e3739b1289
|
@ -47,7 +47,7 @@ class ProxyDumper implements DumperInterface
|
|||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||
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}.
|
||||
|
@ -137,6 +138,7 @@ class ProxyDumperTest extends TestCase
|
|||
$definitions = [
|
||||
[new Definition(__CLASS__), true],
|
||||
[new Definition('stdClass'), true],
|
||||
[new Definition(DumperInterface::class), true],
|
||||
[new Definition(uniqid('foo', true)), false],
|
||||
[new Definition(), false],
|
||||
];
|
||||
|
|
Reference in New Issue