13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Relay \Relay ;
16
- use Symfony \Component \VarExporter \ LazyProxyTrait ;
16
+ use Symfony \Component \Cache \ Traits \ RedisProxyTrait ;
17
17
use Symfony \Component \VarExporter \ProxyHelper ;
18
18
19
19
class RedisProxiesTest extends TestCase
@@ -28,17 +28,17 @@ public function testRedisProxy($class)
28
28
{
29
29
$ version = version_compare (phpversion ('redis ' ), '6 ' , '> ' ) ? '6 ' : '5 ' ;
30
30
$ proxy = file_get_contents (\dirname (__DIR__ , 2 )."/Traits/ {$ class }{$ version }Proxy.php " );
31
- $ expected = substr ($ proxy , 0 , 4 + strpos ($ proxy , '[]; ' ));
31
+ $ expected = substr ($ proxy , 0 , 2 + strpos ($ proxy , '} ' ));
32
32
$ methods = [];
33
33
34
34
foreach ((new \ReflectionClass ($ class ))->getMethods () as $ method ) {
35
- if ('reset ' === $ method ->name || method_exists (LazyProxyTrait ::class, $ method ->name )) {
35
+ if ('reset ' === $ method ->name || method_exists (RedisProxyTrait ::class, $ method ->name )) {
36
36
continue ;
37
37
}
38
- $ return = $ method ->getReturnType () instanceof \ReflectionNamedType && 'void ' === (string ) $ method ->getReturnType () ? '' : 'return ' ;
38
+ $ return = ' __construct ' === $ method -> name || $ method ->getReturnType () instanceof \ReflectionNamedType && 'void ' === (string ) $ method ->getReturnType () ? '' : 'return ' ;
39
39
$ methods [] = "\n " .ProxyHelper::exportSignature ($ method , false , $ args )."\n" .<<<EOPHP
40
40
{
41
- {$ return }( \$this->lazyObjectState->realInstance ??= ( \$ this->lazyObjectState->initializer)() )-> {$ method ->name }( {$ args });
41
+ {$ return }\$this->initializeLazyObject( )-> {$ method ->name }( {$ args });
42
42
}
43
43
44
44
EOPHP ;
@@ -60,17 +60,17 @@ public function testRedisProxy($class)
60
60
public function testRelayProxy ()
61
61
{
62
62
$ proxy = file_get_contents (\dirname (__DIR__ , 2 ).'/Traits/RelayProxy.php ' );
63
- $ proxy = substr ($ proxy , 0 , 4 + strpos ($ proxy , '[]; ' ));
63
+ $ proxy = substr ($ proxy , 0 , 2 + strpos ($ proxy , '} ' ));
64
64
$ methods = [];
65
65
66
66
foreach ((new \ReflectionClass (Relay::class))->getMethods () as $ method ) {
67
- if ('reset ' === $ method ->name || method_exists (LazyProxyTrait ::class, $ method ->name ) || $ method ->isStatic ()) {
67
+ if ('reset ' === $ method ->name || method_exists (RedisProxyTrait ::class, $ method ->name ) || $ method ->isStatic ()) {
68
68
continue ;
69
69
}
70
- $ return = $ method ->getReturnType () instanceof \ReflectionNamedType && 'void ' === (string ) $ method ->getReturnType () ? '' : 'return ' ;
70
+ $ return = ' __construct ' === $ method -> name || $ method ->getReturnType () instanceof \ReflectionNamedType && 'void ' === (string ) $ method ->getReturnType () ? '' : 'return ' ;
71
71
$ methods [] = "\n " .ProxyHelper::exportSignature ($ method , false , $ args )."\n" .<<<EOPHP
72
72
{
73
- {$ return }( \$this->lazyObjectState->realInstance ??= ( \$ this->lazyObjectState->initializer)() )-> {$ method ->name }( {$ args });
73
+ {$ return }\$this->initializeLazyObject( )-> {$ method ->name }( {$ args });
74
74
}
75
75
76
76
EOPHP ;
0 commit comments