diff --git a/src/Core/Intercept/Interceptor.php b/src/Core/Intercept/Interceptor.php index 1e5828b..aebf1ee 100644 --- a/src/Core/Intercept/Interceptor.php +++ b/src/Core/Intercept/Interceptor.php @@ -159,7 +159,7 @@ private function callParentMethod(?object $subject, array $args): mixed $this->unwrapVariadicParameters($parentMethod, $args); - return $parentMethod->invoke($subject, ...array_values($args)); + return $parentMethod->invokeArgs($subject, array_values($args)); } /** diff --git a/src/Core/Transform/WovenClassBuilder.php b/src/Core/Transform/WovenClassBuilder.php index 9858132..1a0ffd7 100644 --- a/src/Core/Transform/WovenClassBuilder.php +++ b/src/Core/Transform/WovenClassBuilder.php @@ -211,9 +211,10 @@ private function buildMethods(): array */ private function buildMethod(BetterReflectionMethod $refMethod): Method { + $refMethod = new ReflectionMethod($refMethod); /** @noinspection PhpUnhandledExceptionInspection */ $method = (new Factory)->fromMethodReflection( - new ReflectionMethod($refMethod), + $refMethod, ); $methodName = $refMethod->getName(); @@ -228,7 +229,7 @@ private function buildMethod(BetterReflectionMethod $refMethod): Method $return = (string)$method->getReturnType() !== 'void' ? 'return ' : ''; // Add parameters as an array with the parameter name as key - $parametersArray = $this->getParametersArray($method); + $parametersArray = $this->getParametersArray($refMethod); $parameters = $parametersArray ? ", $parametersArray" : ''; // Static methods don't have $this @@ -262,11 +263,11 @@ private function buildMethod(BetterReflectionMethod $refMethod): Method * Create an associative array with the parameter name as key and the * parameter as value. * - * @param Method $method + * @param ReflectionMethod $method * * @return string|null */ - private function getParametersArray(Method $method): ?string + private function getParametersArray(ReflectionMethod $method): ?string { $parameters = $method->getParameters(); if (empty($parameters)) { @@ -276,7 +277,8 @@ private function getParametersArray(Method $method): ?string $arguments = []; foreach ($parameters as $parameter) { - $arguments[] = '\'' . $parameter->getName() . '\' => $' . $parameter->getName(); + $isRef = $parameter->isPassedByReference() ? '&' : ''; + $arguments[] = '\'' . $parameter->getName() . '\' => ' . $isRef . '$' . $parameter->getName(); } return '[' . implode(', ', $arguments) . ']';