コード例 #1
0
ファイル: TraitProxy.php プロジェクト: williamamed/Raptor2
    /**
     * Creates definition for trait method body
     *
     * @param ParsedMethod $method Method reflection
     *
     * @return string new method body
     */
    protected function getJoinpointInvocationBody(ParsedMethod $method)
    {
        $isStatic = $method->isStatic();
        $class = '\\' . __CLASS__;
        $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()));
        $args = $scope . ($args ? ", array({$args})" : '');
        return <<<BODY
static \$__joinPoint = null;
if (!\$__joinPoint) {
    \$__joinPoint = {$class}::getJoinPoint(__TRAIT__, __CLASS__, '{$prefix}', '{$method->name}');
}
return \$__joinPoint->__invoke({$args});
BODY;
    }
コード例 #2
0
ファイル: ClassProxy.php プロジェクト: alexrodrigue/framework
 /**
  * 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;
 }