@@ -39,29 +39,25 @@ public function __construct(
39
39
40
40
public function __invoke (\ReflectionClass $ class , array $ propertiesValues , array $ context ): object
41
41
{
42
- if (!isset (self ::$ cache ['lazy_class_name ' ][$ className = $ class ->getName ()])) {
43
- /** @var class-string $lazyClassName */
44
- $ lazyClassName = sprintf ('%sGhost ' , preg_replace ('/ \\\\/ ' , '' , $ className ));
45
- self ::$ cache ['lazy_class_name ' ][$ className ] = $ lazyClassName ;
46
- }
42
+ self ::$ cache ['lazy_class_name ' ][$ className = $ class ->getName ()] ??= sprintf ('%sGhost ' , preg_replace ('/ \\\\/ ' , '' , $ className ));
47
43
48
- if (!isset (self ::$ lazyClassesLoaded [$ className ]) && !class_exists (self ::$ cache ['lazy_class_name ' ][$ className ])) {
49
- if (!file_exists ($ path = sprintf ('%s%s%s.php ' , $ this ->cacheDir , \DIRECTORY_SEPARATOR , hash ('xxh128 ' , $ className )))) {
50
- if (!file_exists ($ this ->cacheDir )) {
51
- mkdir ($ this ->cacheDir , recursive: true );
52
- }
44
+ if (isset (self ::$ lazyClassesLoaded [$ className ]) && class_exists (self ::$ cache ['lazy_class_name ' ][$ className ])) {
45
+ return self ::$ cache ['lazy_class_name ' ][$ className ]::createLazyGhost ($ propertiesValues );
46
+ }
53
47
54
- $ lazyClassName = sprintf ('%sGhost ' , preg_replace ('/ \\\\/ ' , '' , $ className ));
55
- file_put_contents ($ path , sprintf ('class %s%s ' , $ lazyClassName , ProxyHelper::generateLazyGhost ($ class )));
48
+ if (!file_exists ($ path = sprintf ('%s%s%s.php ' , $ this ->cacheDir , \DIRECTORY_SEPARATOR , hash ('xxh128 ' , $ className )))) {
49
+ if (!file_exists ($ this ->cacheDir )) {
50
+ mkdir ($ this ->cacheDir , recursive: true );
56
51
}
57
52
58
- eval (file_get_contents (sprintf ('%s%s%s.php ' , $ this ->cacheDir , \DIRECTORY_SEPARATOR , hash ('xxh128 ' , $ className ))));
59
-
60
- self ::$ lazyClassesLoaded [$ className ] = true ;
53
+ $ lazyClassName = sprintf ('%sGhost ' , preg_replace ('/ \\\\/ ' , '' , $ className ));
54
+ file_put_contents ($ path , sprintf ('class %s%s ' , $ lazyClassName , ProxyHelper::generateLazyGhost ($ class )));
61
55
}
62
56
63
- $ lazyGhost = self ::$ cache ['lazy_class_name ' ][$ className ]::createLazyGhost ($ propertiesValues );
57
+ eval (file_get_contents (sprintf ('%s%s%s.php ' , $ this ->cacheDir , \DIRECTORY_SEPARATOR , hash ('xxh128 ' , $ className ))));
58
+
59
+ self ::$ lazyClassesLoaded [$ className ] = true ;
64
60
65
- return $ lazyGhost ;
61
+ return self :: $ cache [ ' lazy_class_name ' ][ $ className ]:: createLazyGhost ( $ propertiesValues ) ;
66
62
}
67
63
}
0 commit comments