Bug #62988 [Fbk->Csd]: ReflectionParameter::getDefaultValue throws when it shouldn't
| From: | laruence@php.net | Date: | Sat, 01 Sep 2012 11:31:34 +0000 |
| Subject: | Bug #62988 [Fbk->Csd]: ReflectionParameter::getDefaultValue throws when it shouldn't | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173087@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62988&edit=1
ID: 62988
Updated by: laruence@php.net
Reported by: juzna dot cz at gmail dot com
Summary: ReflectionParameter::getDefaultValue throws when it
shouldn't
-Status: Feedback
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: Ubuntu
PHP Version: 5.3.16
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
the fix of #62715 has not been merged(actually only merged one of the two) into
release.
Previous Comments:
------------------------------------------------------------------------
[2012-09-01 11:04:08] juzna dot cz at gmail dot com
Thanks, works as expected.
------------------------------------------------------------------------
[2012-09-01 10:41:47] laruence@php.net
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2012-09-01 08:44:30] juzna dot cz at gmail dot com
Description:
------------
In case an optional parameter is followed by NOT optional parameter, reflection
behaves incorrectly.
On that particular instance of ReflectionParameter, isDefaultValueAvailable()
returns TRUE but getDefaultValue then throws.
I tested it on 5.3.11 where it worked (but where it threw away the default
value), on 5.3.16 it throws.
Test script:
---------------
class Foo {
function bar($a = NULL, $b) { }
}
$rm = new ReflectionMethod('Foo', 'bar');
foreach ($rm->getParameters() as $param) {
echo $param->getName(), "\n";
var_dump($param->isDefaultValueAvailable());
if ($param->isDefaultValueAvailable()) var_dump($param->getDefaultValue());
}
Expected result:
----------------
a
bool(true)
NULL
b
bool(false)
Actual result:
--------------
// on 5.3.16
a
bool(true)
Fatal error: Uncaught exception 'ReflectionException' with message 'Parameter is
not optional'
// on 5.3.11
a
bool(false)
b
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62988&edit=1