|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2012-09-01 10:41 UTC] laruence@php.net
  [2012-09-01 10:41 UTC] laruence@php.net
 
-Status: Open
+Status: Feedback
  [2012-09-01 11:04 UTC] juzna dot cz at gmail dot com
  [2012-09-01 11:31 UTC] laruence@php.net
  [2012-09-01 11:31 UTC] laruence@php.net
 
-Status:      Feedback
+Status:      Closed
-Assigned To:
+Assigned To: laruence
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 02:00:02 2025 UTC | 
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)