当前位置: 首页>>代码示例>>PHP>>正文


PHP Method::set_arg_list方法代码示例

本文整理汇总了PHP中Method::set_arg_list方法的典型用法代码示例。如果您正苦于以下问题:PHP Method::set_arg_list方法的具体用法?PHP Method::set_arg_list怎么用?PHP Method::set_arg_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Method的用法示例。


在下文中一共展示了Method::set_arg_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse_class


//.........这里部分代码省略.........
                     }
                 } else {
                     while ($this->at(',')) {
                         $this->accept();
                         $this->s();
                         $class->add_variable($this->parse_variable($access, $static));
                         $this->s();
                     }
                 }
                 $this->accept(';');
             } elseif ($this->at(T_FUNCTION)) {
                 $this->accept();
                 $this->s();
                 if ($this->at('&')) {
                     $reference = true;
                     $this->accept();
                     $this->s();
                 } else {
                     $reference = false;
                 }
                 if ($this->at(T_CONSTANT_ENCAPSED_STRING)) {
                     if ($access != 'public') {
                         $this->error("pattern matched methods must be public");
                     }
                     if ($final) {
                         $this->error("pattern matched methods cannot be final");
                     }
                     if ($abstract) {
                         $this->error("pattern matched methods cannot be abstract");
                     }
                     if ($reference) {
                         $this->error("pattern matched methods cannot return by reference");
                     }
                     $pattern = $this->current_text();
                     $this->accept();
                     $this->s();
                     $args = $this->parse_arg_list();
                     $this->s();
                     $body = substr($this->parse_block(), 1, -1);
                     if ($static) {
                         $class->add_static_pattern(new Literal($pattern), $args, $body);
                     } else {
                         $class->add_pattern(new Literal($pattern), $args, $body);
                     }
                 } else {
                     $ident = $this->parse_ident();
                     $this->s();
                     $args = $this->parse_arg_list();
                     $this->s();
                     if ($this->at(';')) {
                         $body = '';
                         $this->accept();
                     } else {
                         $body = substr($this->parse_block(), 1, -1);
                     }
                     $method = new Method($ident);
                     $method->set_access($access);
                     $method->set_static($static);
                     $method->set_final($final);
                     $method->set_abstract($abstract);
                     $method->set_reference_returned($reference);
                     $method->set_arg_list($args);
                     $method->set_body($body);
                     $class->add_method($method);
                     if ($member_annotation) {
                         $method->set_annotation($member_annotation);
                     }
                 }
             }
         } elseif ($this->at(T_EVAL)) {
             $this->accept();
             $this->s();
             $code = $this->parse_block();
             class_eval_without_scope($class, $code);
         } elseif ($this->at(T_INCLUDE)) {
             $this->accept();
             $this->s();
             $mixin_method = 'mixin';
             if ($this->at(T_CONST)) {
                 $mixin_method .= '_constants';
                 $this->accept();
                 $this->s();
             } elseif ($this->at(T_STATIC)) {
                 $mixin_method .= '_static';
                 $this->accept();
                 $this->s();
             }
             $module = $this->parse_absolute_namespaced_ident();
             $this->s();
             $this->accept(';');
             $class->{$mixin_method}($module);
         }
         $this->s();
     }
     $this->s();
     $this->accept('}');
     // forward declarations: after
     Forward::apply('after', $class);
     return $class;
 }
开发者ID:jaz303,项目名称:phpx,代码行数:101,代码来源:parser.php

示例2: create_delegate_for_reflection

 /**
  * Creates a Method which, when called, will delegate to a given instance variable
  */
 public static function create_delegate_for_reflection(\ReflectionMethod $method, $variable)
 {
     $method_name = $method->getName();
     $m = new Method($method_name);
     $m->set_arg_list(ArgumentList::create_from_reflection_method($method));
     if ($method->returnsReference()) {
         $m->set_reference_returned(true);
     }
     if ($method->isPublic()) {
         $m->set_access_public();
     } elseif ($method->isProtected()) {
         $m->set_access_protected();
     } elseif ($method->isPrivate()) {
         $m->set_access_private();
     }
     $body = '
         return call_user_func_array(
             array($this->' . $variable . ', "' . $method_name . '"),
             func_get_args()
         );
     ';
     $m->set_body(trim(preg_replace('/\\s+/', ' ', $body)));
     return $m;
 }
开发者ID:jaz303,项目名称:phpx,代码行数:27,代码来源:members.php


注:本文中的Method::set_arg_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。