Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be8fd56

Browse files
committed
minor #39017 [ProxyManagerBridge] replace ProxyManager\Version by feature detection (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [ProxyManagerBridge] replace ProxyManager\Version by feature detection | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - I'd like to get rid of this `Version` class, which is the source of so many issues with deps. This won't remove the class from ocramius/proxy-manager, but that's a separate story that this change could enable in the end :) Commits ------- 5f77aad [ProxyManagerBridge] replace ProxyManager\Version by feature detection
2 parents 5e3338c + 5f77aad commit be8fd56

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
1313

14+
use ProxyManager\Exception\ExceptionInterface;
1415
use ProxyManager\Generator\ClassGenerator;
16+
use ProxyManager\Generator\MethodGenerator;
1517
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
16-
use ProxyManager\Version;
1718
use Symfony\Component\DependencyInjection\Definition;
1819
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
1920

@@ -87,30 +88,21 @@ public function getProxyCode(Definition $definition): string
8788
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
8889
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
8990

90-
if (version_compare(self::getProxyManagerVersion(), '2.2', '<')) {
91+
if (!method_exists(MethodGenerator::class, 'fromReflectionWithoutBodyAndDocBlock')) { // proxy-manager < 2.2
9192
$code = preg_replace(
9293
'/((?:\$(?:this|initializer|instance)->)?(?:publicProperties|initializer|valueHolder))[0-9a-f]++/',
9394
'${1}'.$this->getIdentifierSuffix($definition),
9495
$code
9596
);
9697
}
9798

98-
if (version_compare(self::getProxyManagerVersion(), '2.5', '<')) {
99+
if (!is_subclass_of(ExceptionInterface::class, 'Throwable')) { // proxy-manager < 2.5
99100
$code = preg_replace('/ \\\\Closure::bind\(function ((?:& )?\(\$instance(?:, \$value)?\))/', ' \Closure::bind(static function \1', $code);
100101
}
101102

102103
return $code;
103104
}
104105

105-
private static function getProxyManagerVersion(): string
106-
{
107-
if (!class_exists(Version::class)) {
108-
return '0.0.1';
109-
}
110-
111-
return \defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion();
112-
}
113-
114106
/**
115107
* Produces the proxy class name for the given definition.
116108
*/

0 commit comments

Comments
 (0)