note 83125 added to language.oop5.reflection
| From: | fgm at riff dot org | Date: | Sun, 11 May 2008 19:44:32 +0000 |
| Subject: | note 83125 added to language.oop5.reflection | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139287@lists.php.net to get a copy of this message | ||
The note about the signature of the ReflectionParameter constructor is actually incomplete, at least
in 5.2.5: it is possible to use an integer for the second parameter, and the constructor will use it
to return the n-th parameter.
This allows you to obtain proper ReflectionParameter objects even when documenting code from
extensions which (strangely enough) define several parameters with the same name. The string-based
constructor always returns the first parameter with the matching name, whereas the integer-based
constructor correctly returns the n-th parameter.
So, in short, this works:
<?php
// supposing the extension defined something like:
// Some_Class::someMethod($a, $x, $y, $x, $y)
$p = new ReflectionParameter(array('Some_Class', 'someMethod'), 4);
// returns the last parameter, whereas
$p = new ReflectionParameter(array('Some_Class', 'someMethod'), 'y');
// always returns the first $y at position 2
?>
----
Server IP: 69.147.83.197
Probable Submitter: 82.238.217.133
----
Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php
Edit -- https://master.php.net/note/edit/83125
Del: integrated -- https://master.php.net/note/delete/83125/integrated
Del: useless -- https://master.php.net/note/delete/83125/useless
Del: bad code -- https://master.php.net/note/delete/83125/bad+code
Del: spam -- https://master.php.net/note/delete/83125/spam
Del: non-english -- https://master.php.net/note/delete/83125/non-english
Del: in docs -- https://master.php.net/note/delete/83125/in+docs
Del: other reasons-- https://master.php.net/note/delete/83125
Reject -- https://master.php.net/note/reject/83125
Search -- https://master.php.net/manage/user-notes.php