note 102419 added to reflectionmethod.invokeargs
| From: | agent_harris at secure-mail dot biz | Date: | Sun, 13 Feb 2011 15:12:03 +0000 |
| Subject: | note 102419 added to reflectionmethod.invokeargs | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176950@lists.php.net to get a copy of this message | ||
There is a simple workaround for the reference passing problem:
Since the reflection api has to handle all parameters in a generic way it has no chance to guess if
you wish to pass data per value or reference.
But it seems that you can also decide to pass a reference from where you call the function or method
(not just only by the ampersand prefix in its declaration).
So just do the following; which worked for me:
<?php
...
$method->invoke($object, $inputValue, &$outputValue);
?>
Since this will only be necessary with arrays and primitive data types it should be acceptable in
most cases to know in advance if you need to pass per reference. But it is probably although
necessary to keep the ampersand always in the declaration (because of the at least two layers
between the actual function and your invoke call).
If this is the expected behavior it will maybe make sense to mention it in the documentation for
invoke and invokeArgs.
----
Server IP: 69.147.83.197
Probable Submitter: 84.119.72.250
----
Manual Page -- http://www.php.net/manual/en/reflectionmethod.invokeargs.php
Edit -- https://master.php.net/note/edit/102419
Del: integrated -- https://master.php.net/note/delete/102419/integrated
Del: useless -- https://master.php.net/note/delete/102419/useless
Del: bad code -- https://master.php.net/note/delete/102419/bad+code
Del: spam -- https://master.php.net/note/delete/102419/spam
Del: non-english -- https://master.php.net/note/delete/102419/non-english
Del: in docs -- https://master.php.net/note/delete/102419/in+docs
Del: other reasons-- https://master.php.net/note/delete/102419
Reject -- https://master.php.net/note/reject/102419
Search -- https://master.php.net/manage/user-notes.php