note 81174 added to language.oop5.reflection
| From: | AndreaGiammarchi at osu1 dot php dot net | Date: | Sun, 17 Feb 2008 02:41:56 +0000 |
| Subject: | note 81174 added to language.oop5.reflection | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136213@lists.php.net to get a copy of this message | ||
I encountered a weird problem with ReflectionFunction, described in ticket 44139 of PHP Bugs.
If for some reason you need to call with invoke, or invokeArgs, a function like array_unshift (that
accepts internally the array by reference) you could use this code to avoid the generated warning or
fatal error.
<?php
function unshift(){
$ref = new ReflectionFunction('array_unshift');
$arguments = func_get_args();
return $ref->invokeArgs(array_merge(array(&$this->arr), $arguments));
}
?>
I don't know about performances (you can create an array manually too, starting from
array(&$this->something) and adding arguments). However, it seems to work correctly without
problems, at least until the send by reference will be usable with one single value ...
----
Server IP: 208.69.120.35
Probable Submitter: 80.42.177.18
----
Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php
Edit -- https://master.php.net/note/edit/81174
Del: integrated -- https://master.php.net/note/delete/81174/integrated
Del: useless -- https://master.php.net/note/delete/81174/useless
Del: bad code -- https://master.php.net/note/delete/81174/bad+code
Del: spam -- https://master.php.net/note/delete/81174/spam
Del: non-english -- https://master.php.net/note/delete/81174/non-english
Del: in docs -- https://master.php.net/note/delete/81174/in+docs
Del: other reasons-- https://master.php.net/note/delete/81174
Reject -- https://master.php.net/note/reject/81174
Search -- https://master.php.net/manage/user-notes.php