/** * Creates definition for method body * * @param Method|ParsedMethod $method Method reflection * * @return string new method body */ protected function getJoinpointInvocationBody($method) { $isStatic = $method->isStatic(); $scope = $isStatic ? $this->staticLsbExpression : '$this'; $prefix = $isStatic ? AspectContainer::STATIC_METHOD_PREFIX : AspectContainer::METHOD_PREFIX; $args = join(', ', array_map(function ($param) { /** @var $param Parameter|ParsedParameter */ $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; }