8000 [ProxyManager] isProxyCandidate() does not take into account interfaces by andrerom · Pull Request #31551 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[ProxyManager] isProxyCandidate() does not take into account interfaces #31551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
[Bridge\ProxyManager] isProxyCandidate() does not take into account i…
…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
commit e3739b1289fe2d10eacc92462e198271e4338216
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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