/** * Checks the parameters of the call against the given ones * * @param PC_Obj_Call $call the call * @param PC_Obj_Method $method the method */ private function check_params($call, $method) { $arguments = $call->get_arguments(); $nparams = $method->get_required_param_count(); $nmaxparams = $method->get_param_count(); if (count($arguments) < $nparams || $nmaxparams >= 0 && count($arguments) > $nmaxparams) { if ($nparams != $nmaxparams) { $reqparams = $nparams . ' to ' . ($nmaxparams == -1 ? '*' : $nmaxparams); } else { $reqparams = $nparams; } $this->report($call, 'The function/method called by "' . $this->get_call_link($call) . '" requires ' . $reqparams . ' arguments but you have given ' . count($arguments), PC_Obj_Error::E_S_WRONG_ARGUMENT_COUNT); } else { $i = 0; foreach ($method->get_params() as $param) { /* @var $param PC_Obj_Parameter */ $arg = isset($arguments[$i]) ? $arguments[$i] : null; // arg- or param-type unknown? if ($arg === null || $arg->is_unknown() || $param->get_mtype()->is_unknown()) { $i++; continue; } if (!$this->is_argument_ok($call, $arg, $param)) { $trequired = $param->get_mtype(); $tactual = $arg; $this->report($call, 'The parameter ' . ($i + 1) . ' in "' . $this->get_call_link($call) . '" requires ' . $this->get_article($trequired) . ' "' . $trequired . '" but you have given ' . $this->get_article($tactual) . ' "' . ($tactual === null ? "<i>NULL</i>" : $tactual) . '"', PC_Obj_Error::E_S_WRONG_ARGUMENT_TYPE); } $i++; } } }
/** * Builds the fields to insert / update in the db * * @param PC_Obj_Method $function the function/method * @param int $class the id of the class the function belongs to * @param int $pid the project-id (default = current) * @return array all fields */ private function get_fields($function, $class, $pid = PC_Project::CURRENT_ID) { $params = serialize($function->get_params()); return array('project_id' => PC_UTils::get_project_id($pid), 'file' => $function->get_file(), 'line' => $function->get_line(), 'class' => $class, 'name' => $function->get_name(), 'abstract' => $function->is_abstract() ? 1 : 0, 'final' => $function->is_final() ? 1 : 0, 'static' => $function->is_static() ? 1 : 0, 'anonymous' => $function->is_anonymous() ? 1 : 0, 'visibility' => $function->get_visibility(), 'return_type' => serialize(array($function->has_return_doc(), $function->get_return_type())), 'throws' => serialize($function->get_throws()), 'params' => $params, 'min_version' => serialize($function->get_version()->get_min()), 'max_version' => serialize($function->get_version()->get_max())); }