8000 [Bridge\ProxyManager] isProxyCandidate() does not take into account i… · symfony/symfony@9f8358e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f8358e

Browse files
committed
[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.
1 parent 78d86f8 commit 9f8358e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct($salt = '')
4444
*/
4545
public function isProxyCandidate(Definition $definition)
4646
{
47-
return $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class);
47+
return $definition->isLazy() && ($class = $definition->getClass()) && (class_exists($class) || interface_exists($class));
4848
}
4949

5050
/**

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function getProxyCandidates()
8787
$definitions = array(
8888
array(new Definition(__CLASS__), true),
8989
array(new Definition('stdClass'), true),
90+
array(new Definition('Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface'), true),
9091
array(new Definition(uniqid('foo', true)), false),
9192
array(new Definition(), false),
9293
);

0 commit comments

Comments
 (0)
0