/** * Creates definition for method body * * @param ParsedMethod $method Method reflection * * @return string new method body */ protected function getJoinpointInvocationBody(ParsedMethod $method) { $isStatic = $method->isStatic(); $scope = $isStatic ? $this->staticLsbExpression : '$this'; $prefix = $isStatic ? AspectContainer::STATIC_METHOD_PREFIX : AspectContainer::METHOD_PREFIX; $args = join(', ', array_map(function (ParsedParameter $param) { $byReference = $param->isPassedByReference() ? '&' : ''; return $byReference . '$' . $param->name; }, $method->getParameters())); $body = ''; if ($this->class->name === $method->getDeclaringClassName() && strpos($method->getSource(), 'func_get_args') !== false) { $body = '$argsList = \\func_get_args();' . PHP_EOL; if (empty($args)) { $scope = "{$scope}, \$argsList"; } else { $scope = "{$scope}, array({$args}) + \$argsList"; } } elseif (!empty($args)) { $scope = "{$scope}, array({$args})"; } $body .= "return self::\$__joinPoints['{$prefix}:{$method->name}']->__invoke({$scope});"; return $body; }
/** * Creates a parameter alias for the given method. * * @param \TokenReflection\ReflectionMethod $parent New parent method * @return \TokenReflection\ReflectionParameter */ public function alias(ReflectionMethod $parent) { $parameter = clone $this; $parameter->declaringClassName = $parent->getDeclaringClassName(); $parameter->declaringFunctionName = $parent->getName(); return $parameter; }