|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-11-19 18:21 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-11-19 18:21 UTC] requinix@php.net
[2015-11-19 22:07 UTC] devosc at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Description: ------------ The order in which an optional parameter is specified should not matter. However, currently, when an optional parameter occurs before a required parameter in a constructor or function argument, the Reflection package is incorrectly identifying the optional parameter as being a required parameter. Test script: --------------- <?php class A {} class B { function __construct($b = null, A $a) {} } Reflection::export(new ReflectionClass('B')); class C { function __construct(A $a, $b = null) {} } Reflection::export(new ReflectionClass('C')); https://3v4l.org/gKhZ6 https://3v4l.org/Yt2JN Expected result: ---------------- Parameter b should be optional regardless of its position in a constructor or function argument. Actual result: -------------- Class [ <user> class B ] { @@ ./index.php 10-12 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [1] { Method [ <user, ctor> public method __construct ] { @@ ./index.php 11 - 11 - Parameters [2] { Parameter #0 [ <required> $b ] Parameter #1 [ <required> A $a ] } } } } Class [ <user> class C ] { @@ ./index.php 16-18 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [1] { Method [ <user, ctor> public method __construct ] { @@ ./index.php 17 - 17 - Parameters [2] { Parameter #0 [ <required> A $a ] Parameter #1 [ <optional> $b = NULL ] } } } }