From 3ca65b8edb8d96b46fedc9bb4911396516347129 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 16 May 2023 15:15:01 +0200 Subject: [PATCH] Fix generating proxies for arguments promoted as properties --- src/ProxyManager/Generator/MethodGenerator.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ProxyManager/Generator/MethodGenerator.php b/src/ProxyManager/Generator/MethodGenerator.php index a259b9c8..3c612144 100644 --- a/src/ProxyManager/Generator/MethodGenerator.php +++ b/src/ProxyManager/Generator/MethodGenerator.php @@ -6,6 +6,7 @@ use Laminas\Code\Generator\DocBlockGenerator; use Laminas\Code\Generator\MethodGenerator as LaminasMethodGenerator; +use Laminas\Code\Generator\ParameterGenerator; use Laminas\Code\Reflection\MethodReflection; use ReflectionException; use ReflectionMethod; @@ -23,7 +24,7 @@ class MethodGenerator extends LaminasMethodGenerator public static function fromReflectionWithoutBodyAndDocBlock(MethodReflection $reflectionMethod): self { /** @var static $method */ - $method = parent::copyMethodSignature($reflectionMethod); + $method = static::copyMethodSignature($reflectionMethod); $method->setInterface(false); $method->setBody(''); @@ -55,6 +56,19 @@ public static function fromReflectionWithoutBodyAndDocBlock(MethodReflection $re return $method; } + public static function copyMethodSignature(MethodReflection $reflectionMethod): parent + { + $method = parent::copyMethodSignature($reflectionMethod); + + foreach ($reflectionMethod->getParameters() as $reflectionParameter) { + $method->setParameter( + ParameterGenerator::fromReflection($reflectionParameter) + ); + } + + return $method; + } + public function getDocBlock(): ?DocBlockGenerator { $docBlock = parent::getDocBlock();