當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Method::set_reference_returned方法代碼示例

本文整理匯總了PHP中Method::set_reference_returned方法的典型用法代碼示例。如果您正苦於以下問題:PHP Method::set_reference_returned方法的具體用法?PHP Method::set_reference_returned怎麽用?PHP Method::set_reference_returned使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Method的用法示例。


在下文中一共展示了Method::set_reference_returned方法的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_reference_returned方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。