From: missingno at ifrance dot com Operating system: Any PHP version: 5.2CVS-2008-07-20 (snap) PHP Bug Type: Feature/Change Request Bug description: Suggestions for reflection API
Description: ------------ I'm only submitting a suggestion made by Niels Jaeckel on the Reflection API which I think may be valuable. See http://docs.php.net/reflection for the original post. Niels suggested that a new object be created called ReflectionConstant. ReflectionClass::getConstants() [and maybe also ReflectionExtension::getConstants()] should be changed to return an array of such objects. This way, it would be possible to read DocComments for class constants. Also, there is currently no way to retrieve the type hint of a given parameter (in ReflectionParameter). Maybe I should fill another bug report for this one ? Reproduce code: --------------- <?php class MyCharacter { /* some stuff here */ } class MyString { /** ASCII string */ const TYPE_ASCII = 1; /** Unicode string */ const TYPE_UNICODE = 2; public function __construct(MyCharacter $char, $type) { /* do something useful here */ } } $class = new ReflectionClass('MyString'); foreach ($class->getConstants as $constant) { echo $constant->getName()." = ".$constant->getValue()." (".$contant->getDocComment().")\r\n"; } echo "\r\n"; $method = new ReflectionMethod('MyString', '__construct'); foreach ($method->getParameters as $parameter) { echo "Type hint for ".$param->getName()." is ".$param->getTypeHint().".\r\n"; } ?> Expected result: ---------------- I would expect something like the following to be echoed: TYPE_ASCII = 1 (ASCII string) TYPE_UNICODE = 2 (Unicode string) Type hint for char is MyCharacter. Type hint for type is . // getTypeHint() could return NULL or FALSE if no type hint was given. Actual result: -------------- This is currently no way of retrieving the DocComment of a class constant. There is also no way of retrieving information about type hinting in methods' parameters.for -- Edit bug report at http://bugs.php.net/?id=45569&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45569&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45569&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45569&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45569&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45569&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45569&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45569&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45569&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45569&r=support Expected behavior: http://bugs.php.net/fix.php?id=45569&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45569&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45569&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45569&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45569&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45569&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45569&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45569&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45569&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45569&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45569&r=mysqlcfg
