Description:
------------
When a constant is used for the default value of an optional parameter, the Reflection API (tries to) resolve(s) the constant to its value and then returns it as the default value.
In addition, I would like to have two additional methods in ReflectionParameter that expose 1) whether or not a default value "is a" constant and 2) the name of the constant.
In the example below, I am using temporary names ("defaultValueIsConstant" and "getDefaultValueConstantName") for these two methods because I cannot think of sensible method names right now.
Test script:
---------------
<?php
class Foo {
const bar = '...';
public function baz($bar = self::bar) {
}
}
$m = new ReflectionMethod('Foo', 'baz');
$p = $m->getParameters();
foreach ($p as $_p) {
var_dump($_p->getDefaultValue());
if ($_p->defaultValueIsConstant()) {
var_dump($_p->getDefaultValueConstantName());
}
}
Expected result:
----------------
string(3) "..."
string(9) "self::bar"
Actual result:
--------------
string(3) "..."

This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.