本文整理汇总了PHP中Generator::is_php_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::is_php_type方法的具体用法?PHP Generator::is_php_type怎么用?PHP Generator::is_php_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator::is_php_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genReflectionArgInfo
/**
* generates an ZEND_ARGINFO entry for this method
* based on the parameters and returns it
*
* @param Method $method The method (or constructor) to generate the arginfo for (if NULL, then we check for overridden only)
* @param Class $class The class of the method
* @param string $det_method_name Special determined method name if it can't be calculated from the method object
* @return array The arginfo (string) and the name of the reflection function
*/
function genReflectionArgInfo($method, $class, $det_method_name = null)
{
if ($det_method_name !== null) {
$len = 20 - strlen($det_method_name);
} else {
$len = 20 - strlen($method->name);
}
if ($len < 0) {
$len = 0;
}
if ($method === null || ($overriden = $this->overrides->is_overriden($method->c_name))) {
//overridden function - extra arginfo in override file?
$class_name = $class->c_name;
if ($det_method_name !== null) {
$method_name = $det_method_name;
} else {
$overrideinfo = $this->overrides->get_override($method->c_name);
$method_name = $overrideinfo[0];
if (empty($method_name) || $method_name == $method->c_name) {
$method_name = $method->name;
}
}
if ($this->overrides->has_extra_arginfo($class_name, $method_name)) {
$reflection_funcname = Generator::getReflectionFuncName($method, $class, $det_method_name);
$reflection_func = str_repeat(' ', $len) . $reflection_funcname;
$arginfo = str_replace('ARGINFO_NAME', $reflection_funcname, $this->overrides->get_extra_arginfo($class_name, $method_name));
} else {
//no arginfo
$reflection_func = str_repeat(' ', $len) . 'NULL';
$arginfo = null;
//var_dump('No arginfo for overridden ' . $reflection_funcname);
}
} else {
if (count($method->params) == 0) {
$reflection_func = str_repeat(' ', $len) . 'NULL';
$arginfo = null;
} else {
$reflection_funcname = Generator::getReflectionFuncName($method, $class);
$reflection_func = str_repeat(' ', $len) . $reflection_funcname;
$param_count = 0;
$optparam_count = 0;
$argparams = '';
foreach ($method->params as $paraminfo) {
$param_count++;
if ($paraminfo[2] !== null) {
//if this is set, we've got a default value -> optional parameter
$optparam_count++;
}
$paramtype = str_replace('const-', '', str_replace('*', '', $paraminfo[0]));
if (Generator::is_php_type($paramtype)) {
$argparams .= sprintf(Templates::reflection_arg, $paraminfo[1]);
} else {
$argparams .= sprintf(Templates::reflection_objarg, $paraminfo[1], $paramtype);
}
}
if ($optparam_count > 0) {
//with optional count
$arginfo = sprintf(Templates::reflection_arginfoex_begin, $reflection_funcname, $param_count - $optparam_count);
} else {
//simple one
$arginfo = sprintf(Templates::reflection_arginfo_begin, $reflection_funcname);
}
$arginfo .= $argparams;
$arginfo .= Templates::reflection_arginfo_end;
}
}
return array($arginfo, $reflection_func);
}