|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-10-26 11:05 UTC] sebastian@php.net
Description:
------------
ReflectionMethod::invoke*() does not work for methods that expect pass-by-reference arguments.
Test script:
---------------
<?php
class Foo
{
public function bar(&$baz)
{
}
}
$array = array();
$object = new Foo;
$method = new ReflectionMethod('Foo', 'bar');
$method->invoke($object, $array);
?>
Actual result:
--------------
Warning: Parameter 1 to Foo::bar() expected to be a reference, value given in /home/sb/test.php on line 13
Fatal error: Uncaught exception 'ReflectionException' with message 'Invocation of method Foo::bar() failed' in /home/sb/test.php:13
Stack trace:
#0 /home/sb/test.php(13): ReflectionMethod->invoke(Object(Foo), Array)
#1 {main}
thrown in /home/sb/test.php on line 13
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
invokeArgs() works: <?php class Foo { public function bar(&$baz) { } } $array = array(); $object = new Foo; $method = new ReflectionMethod('Foo', 'bar'); $method->invokeArgs($object, array(&$array)); ?>