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