diff --git a/src/ContainerCompiled.php b/src/ContainerCompiled.php index 4b9466d..ae72ce4 100644 --- a/src/ContainerCompiled.php +++ b/src/ContainerCompiled.php @@ -57,7 +57,7 @@ public function get(string $id): object * * @psalm-suppress MixedMethodCall */ - $instance = new $proxyClass($this); + $instance = new $proxyClass($this->decorated); return $instance; } diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index 64312c3..1309ed8 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -200,10 +200,8 @@ private function createProxyClass( string $methods, bool $isInterface, ): string { - $template = "final readonly class %s %s %s + $template = "final %s class %s %s %s { - private ?%s \$_proxiedObject; - public function __construct( private \Psr\Container\ContainerInterface \$container ) { @@ -222,11 +220,11 @@ private function _proxied(): %s return \sprintf( $template, + $classRef->isReadOnly() ? 'readonly' : '', $proxyClassName, $isInterface ? 'implements' : 'extends', $fullClassName, $fullClassName, - $fullClassName, $this->createProxyClassConstructor($classRef), $methods );