Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e24e7dc

Browse filesBrowse files
bug symfony#31551 [ProxyManager] isProxyCandidate() does not take into account interfaces (andrerom)
This PR was merged into the 3.4 branch. Discussion ---------- [ProxyManager] isProxyCandidate() does not take into account interfaces | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | N/A When using factories it's common best practice to use interface as class name, especially in cases where you know implementation can differ. Before this fix ProxyManager did not allow these to be lazy. As we have have this issue on 2.8 and 3.4. it's very hard to debug, and goes against best practice for factories to not fix it, this is suggested for 2.8. Commits ------- e3739b1 [Bridge\ProxyManager] isProxyCandidate() does not take into account interfaces
2 parents 365a390 + e3739b1 commit e24e7dc
Copy full SHA for e24e7dc

File tree

2 files changed

+3
-1
lines changed
Filter options

2 files changed

+3
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct($salt = '')
4747
*/
4848
public function isProxyCandidate(Definition $definition)
4949
{
50-
return $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class);
50+
return $definition->isLazy() && ($class = $definition->getClass()) && (class_exists($class) || interface_exists($class));
5151
}
5252

5353
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Definition;
18+
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
1819

1920
/**
2021
* Tests for {@see \Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper}.
@@ -137,6 +138,7 @@ public function getProxyCandidates()
137138
$definitions = [
138139
[new Definition(__CLASS__), true],
139140
[new Definition('stdClass'), true],
141+
[new Definition(DumperInterface::class), true],
140142
[new Definition(uniqid('foo', true)), false],
141143
[new Definition(), false],
142144
];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.