diff --git a/src/AspectWeaver.php b/src/AspectWeaver.php index 4515618..57e4c05 100644 --- a/src/AspectWeaver.php +++ b/src/AspectWeaver.php @@ -179,12 +179,13 @@ class AspectWeaver array $methodAspectsMap, string $modifiedSource ): string { + $originalClassName = $namespace ? "{$namespace}\\{$shortName}" : $shortName; $code = "generateProxyMethodFromReflection($methodMetadata->method, $methodMetadata->aspects); + $code .= $this->generateProxyMethodFromReflection($methodMetadata->method, $methodMetadata->aspects, $originalClassName); } $code .= "}\n"; @@ -201,6 +202,7 @@ class AspectWeaver string $renamedClassName, array $methodAspectsMap ): string { + $originalClassName = $namespace ? "{$namespace}\\{$shortName}" : $shortName; $code = ''; if ($namespace) { @@ -210,7 +212,7 @@ class AspectWeaver $code .= "class {$shortName} extends {$renamedClassName}\n{\n"; foreach ($methodAspectsMap as $methodMetadata) { - $code .= $this->generateProxyMethodFromReflection($methodMetadata->method, $methodMetadata->aspects); + $code .= $this->generateProxyMethodFromReflection($methodMetadata->method, $methodMetadata->aspects, $originalClassName); } $code .= "}\n"; @@ -221,13 +223,12 @@ class AspectWeaver /** * @param array $aspects */ - private function generateProxyMethodFromReflection(ReflectionMethod $method, array $aspects): string + private function generateProxyMethodFromReflection(ReflectionMethod $method, array $aspects, string $className): string { $visibility = $method->isPublic() ? 'public' : 'protected'; $static = $method->isStatic() ? 'static ' : ''; $isStatic = $method->isStatic(); $name = $method->getName(); - $className = $method->getDeclaringClass()->getName(); $this->logger->info('Generating proxy method', [ 'class' => $className,