|
11 | 11 |
|
12 | 12 | namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
|
13 | 13 |
|
| 14 | +use ProxyManager\Exception\ExceptionInterface; |
14 | 15 | use ProxyManager\Generator\ClassGenerator;
|
| 16 | +use ProxyManager\Generator\MethodGenerator; |
15 | 17 | use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
|
16 |
| -use ProxyManager\Version; |
17 | 18 | use Symfony\Component\DependencyInjection\Definition;
|
18 | 19 | use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
|
19 | 20 |
|
@@ -87,30 +88,21 @@ public function getProxyCode(Definition $definition): string
|
87 | 88 | $code = $this->classGenerator->generate($this->generateProxyClass($definition));
|
88 | 89 | $code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
|
89 | 90 |
|
90 |
| - if (version_compare(self::getProxyManagerVersion(), '2.2', '<')) { |
| 91 | + if (!method_exists(MethodGenerator::class, 'fromReflectionWithoutBodyAndDocBlock')) { // proxy-manager < 2.2 |
91 | 92 | $code = preg_replace(
|
92 | 93 | '/((?:\$(?:this|initializer|instance)->)?(?:publicProperties|initializer|valueHolder))[0-9a-f]++/',
|
93 | 94 | '${1}'.$this->getIdentifierSuffix($definition),
|
94 | 95 | $code
|
95 | 96 | );
|
96 | 97 | }
|
97 | 98 |
|
98 |
| - if (version_compare(self::getProxyManagerVersion(), '2.5', '<')) { |
| 99 | + if (!is_subclass_of(ExceptionInterface::class, 'Throwable')) { // proxy-manager < 2.5 |
99 | 100 | $code = preg_replace('/ \\\\Closure::bind\(function ((?:& )?\(\$instance(?:, \$value)?\))/', ' \Closure::bind(static function \1', $code);
|
100 | 101 | }
|
101 | 102 |
|
102 | 103 | return $code;
|
103 | 104 | }
|
104 | 105 |
|
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 |
| - |
114 | 106 | /**
|
115 | 107 | * Produces the proxy class name for the given definition.
|
116 | 108 | */
|
|
0 commit comments