parent root
PHP: ReflectionFunctionAbstract::getParameters - Manual

ReflectionFunctionAbstract::getParameters

(PHP 5 >= 5.2.0, PHP 7)

ReflectionFunctionAbstract::getParametersGets parameters

Description

public ReflectionFunctionAbstract::getParameters ( void ) : array

Get the parameters as an array of ReflectionParameter.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

The parameters, as a ReflectionParameter object.

See Also

add a noteadd a note

User Contributed Notes 1 note

up
7
dabidi at slupca dot pl
3 years ago
This is part of my private framework that uses reflection.
This function get arguments list from theme method and puts corresponding vars from $_REQUEST ($_GET, $_POST, and $_COOKIE)

<?php
public static function fire_theme_method($class, $method)
{
       
$fire_args=array();
       
       
$reflection = new ReflectionMethod($class, $method);

    foreach(
$reflection->getParameters() AS $arg)
    {
        if(
$_REQUEST[$arg->name])
       
$fire_args[$arg->name]=$_REQUEST[$arg->name];
        else
       
$fire_args[$arg->name]=null;
    }
       
    return
call_user_func_array(array($class, $method), $fire_args);
}
?>
For example, if my theme method needs only id, and we get this url:
http://example.com/my_class/my_method/?id=12&some_unwanted_var=123
will be ignored some_unwanted_var

Of course behind this i have .htaccess, autoloader and controller
To Top
parent root