note 100517 added to reflectionmethod.invokeargs
| From: | contato at andersonfraga dot net | Date: | Thu, 21 Oct 2010 02:35:37 +0000 |
| Subject: | note 100517 added to reflectionmethod.invokeargs | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173327@lists.php.net to get a copy of this message | ||
InvokeArgs doesn't accept named parameters with your keys:
<?php
class Test {
public function methodHere($arg1, $arg2, $arg3) {
echo '<pre>';
echo $arg1 . PHP_EOL;
echo $arg2 . PHP_EOL;
echo $arg3 . PHP_EOL;
echo '</pre>';
}
}
$ref_test = new ReflectionClass('Test');
$ref_method = $ref_test->getMethod('methodHere');
$list_args = Array(
'arg2' => 'apple',
'arg1' => 'wine',
'arg4' => 'arch enemy', // what? arg4??
);
$ref_method->invokeArgs(new Test(), $list_args);
/**
print:
apple
wine
thats all folks!
*/
?>
This is not good...
----
Server IP: 187.16.23.134
Probable Submitter: 200.143.116.14
----
Manual Page -- http://www.php.net/manual/en/reflectionmethod.invokeargs.php
Edit -- https://master.php.net/note/edit/100517
Del: integrated -- https://master.php.net/note/delete/100517/integrated
Del: useless -- https://master.php.net/note/delete/100517/useless
Del: bad code -- https://master.php.net/note/delete/100517/bad+code
Del: spam -- https://master.php.net/note/delete/100517/spam
Del: non-english -- https://master.php.net/note/delete/100517/non-english
Del: in docs -- https://master.php.net/note/delete/100517/in+docs
Del: other reasons-- https://master.php.net/note/delete/100517
Reject -- https://master.php.net/note/reject/100517
Search -- https://master.php.net/manage/user-notes.php