#41382 [Opn->Bgs]: ReflectionParameter isDefaultValueAvailable() is not working as expected
| From: | johannes@php.net | Date: | Sun, 13 May 2007 10:30:38 +0000 |
| Subject: | #41382 [Opn->Bgs]: ReflectionParameter isDefaultValueAvailable() is not working as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112596@lists.php.net to get a copy of this message | ||
ID: 41382
Updated by: johannes@php.net
Reported By: hasin at pageflakes dot com
-Status: Open
+Status: Bogus
Bug Type: SPL related
Operating System: Windows XP
PHP Version: 5.2.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
In your example $b and $c arent optional since an parameter without
default value ($d) is present afterwards, too. We dont store these
values since the engine needs default values only for optional
parameters.
See also example 17.9
http://de3.php.net/manual/en/functions.arguments.php
Previous Comments:
------------------------------------------------------------------------
[2007-05-13 09:39:20] hasin at pageflakes dot com
Description:
------------
The isDefaultValueAvailable() of ReflectionParameter object doesn't
return true for any parameter if the next parameter in collection has no
default value. To regenerate the bug, execute the following script
Reproduce code:
---------------
<?
class TestClass
{
public function __construct($a , $b=6 , $c = "hh", $d, $e=76)
{
}
}
$class = new ReflectionClass("TestClass");
$method= $class->getMethod("__construct");
$parameter = $method->getParameters();
foreach ($parameter as $param)
{
if ($param->isDefaultValueAvailable())
{
if (is_null($param->getDefaultValue()))
echo $param->getName()." : null \n";
else
echo $param->getName()." : ".$param->getDefaultValue()."\n";
}
}
?>
Expected result:
----------------
b : 6
c : hh
e : 76
Actual result:
--------------
e : 76
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41382&edit=1