/** * 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); }