|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-08-20 14:04 UTC] laruence@php.net
[2012-08-20 14:13 UTC] laruence@php.net
-Assigned To:
+Assigned To: laruence
[2012-08-20 14:27 UTC] karsten at typo3 dot org
[2012-08-21 05:41 UTC] laruence@php.net
-Status: Assigned
+Status: Feedback
[2012-08-21 05:41 UTC] laruence@php.net
[2012-08-21 05:42 UTC] laruence@php.net
[2012-08-21 07:45 UTC] karsten at typo3 dot org
[2012-08-21 10:08 UTC] laruence@php.net
-Status: Feedback
+Status: Closed
[2012-08-21 10:08 UTC] laruence@php.net
[2012-08-21 12:26 UTC] crash__ at hotmail dot fr
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
Description: ------------ If isDefaultValueAvailable() returns TRUE I expect to be able to call getDefaultValue() Test script: --------------- <?php class a { protected function test(array $a = NULL, $b, array $c = NULL) {} } $class = new ReflectionClass('a'); foreach ($class->getMethods() as $method) { foreach ($method->getParameters() as $p) { echo $p->getName() . "\n"; echo " isDefaultValueAvailable: " . var_export($p->isDefaultValueAvailable(), true) . "\n"; if ($p->isDefaultValueAvailable()) { echo " default value: " . var_export($p->getDefaultValue(), true) . "\n"; } echo " isOptional: " . var_export($p->isOptional(), true) . "\n"; echo " allowsNull: " . var_export($p->allowsNull(), true) . "\n"; echo "\n"; } } ?> Expected result: ---------------- a isDefaultValueAvailable: true default value: NULL isOptional: false allowsNull: true b isDefaultValueAvailable: false isOptional: false allowsNull: true c isDefaultValueAvailable: true default value: NULL isOptional: true allowsNull: true Actual result: -------------- a isDefaultValueAvailable: true Fatal error: Uncaught exception 'ReflectionException' with message 'Parameter is not optional' in test.php on line 12 ReflectionException: Parameter is not optional in test.php on line 12 Call Stack: 0.0010 646632 1. {main}() test.php:0 0.0011 651128 2. ReflectionParameter->getDefaultValue() test.php:12