downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ReflectionFunctionAbstract::getNumberOfRequiredParameters> <ReflectionFunctionAbstract::getNamespaceName
[edit] Last updated: Fri, 24 May 2013

view this page in

ReflectionFunctionAbstract::getNumberOfParameters

(PHP 5 >= 5.0.3)

ReflectionFunctionAbstract::getNumberOfParametersGets number of parameters

Descrição

public int ReflectionFunctionAbstract::getNumberOfParameters ( void )

Get the number of parameters that a function defines, both optional and required.

Aviso

Esta função não está documentada; somente a lista de argumentos está disponível.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

The number of parameters.

Veja Também



add a note add a note User Contributed Notes ReflectionFunctionAbstract::getNumberOfParameters - [1 notes]
up
1
Robert Pitt ( LitePHP )
3 years ago
Working on a new MVC Application Framework i use this method to check how many arguments are required before calling the sub method!

Example

<?php
        $this
->method_args_count = $this->CReflection
           
->getMethod($Route->getMethod())
            ->
getNumberOfParameters();
       
//Maybe be 5 but if uri is /controller/method/single_param/ we only of 1
       
$this->params = $Route->getParams(); //0 in some cases

       
if($this->method_args_count > count($this->params))
        {
           
$this->difference = ($this->method_args_count - count($this->params));
            for(
$i=0;$i<=$this->difference;$i++)
            {
               
$this->params[] = false;
            }
        }
       
       
//Call the method with correct amount of params
        // but as false for params that have not been passed!
       
call_user_func_array(array(new $this->obj,$Route->getMethod()),$this->params);
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites