I was debugging the service locator and proxy object in PHP5.4, the bug was the Reflection fail to get parameters properly from predefined class method, but works well from user defined.
example :
# proxy class
# arguments are pre-populated
$rc = new ReflectionClass('PDOStatement');
var_dump($rc->getMethod('fetchAll')->getParameters());
would print
array (size=3)
0 => &
object(ReflectionParameter)[5]
public 'name' => string 'how' (length=3)
1 => &
object(ReflectionParameter)[6]
public 'name' => string 'class_name' (length=10)
2 => &
object(ReflectionParameter)[7]
public 'name' => string 'ctor_args' (length=9)
the name clearly different from documentation in http://ift.tt/1NCr5iP
public array fetchAll ([ int $fetch_style [, mixed $fetch_argument [, array $ctor_args = array() ]]] )
even more failure in ArrayObject, missing 2 parameter
# service locator
# arguments (__construct) are pre-populated
$rc = new ReflectionClass('ArrayObject');
var_dump($rc->getConstructor()->getParameters());
would print
array (size=1)
0 => &
object(ReflectionParameter)[4]
public 'name' => string 'array' (length=5)
documentation http://ift.tt/1GN4cJu
public __construct ([ mixed $input = [] [, int $flags = 0 [, string $iterator_class = "ArrayIterator" ]]] )
is there any way to get real parameters for predefined class method? and please don't discuss about anti-pattern service locator.
thanks
Aucun commentaire:
Enregistrer un commentaire