Bug #76131 [Opn]: ReflectionParameter names and documentation variable names not matching up
| From: | cmb@php.net | Date: | Sat, 24 Mar 2018 13:12:18 +0000 |
| Subject: | Bug #76131 [Opn]: ReflectionParameter names and documentation variable names not matching up | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214464@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76131&edit=1
ID: 76131
Updated by: cmb@php.net
Reported by: timothy dot fisher at riosalado dot edu
Summary: ReflectionParameter names and documentation variable
names not matching up
Status: Open
Type: Bug
Package: Reflection related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
See <https://github.com/php/php-src/pull/3193>.
Previous Comments:
------------------------------------------------------------------------
[2018-03-21 22:47:10] timothy dot fisher at riosalado dot edu
Description:
------------
---
From:
http://php.net/manual/en/datetime.construct.php
http://php.net/manual/en/arrayobject.construct.php
---
---
See: https://stackoverflow.com/q/49416234/5749974
---
When reflecting on some native PHP class constructs, the names of the parameters do not match up to
the names of the variables in the PHP docs. It also seems as if the type-hint in the docs of the
DateTime constructor are missing when using the ReflectionParameter::getClass() method.
Test script:
---------------
---
See: https://stackoverflow.com/q/49416234/5749974
---
$reflector = new ReflectionClass('DateTime');
$constructor = $reflector->getConstructor();
if ($constructorParams = $constructor->getParameters()) {
foreach ($constructorParams as $i => $param) {
$name = $param->getClass() ? $param->getClass()->name : $param->name;
var_dump($name);
}
}
$reflector = new ReflectionClass('ArrayObject');
$constructor = $reflector->getConstructor();
if ($constructorParams = $constructor->getParameters()) {
foreach ($constructorParams as $i => $param) {
$name = $param->getClass() ? $param->getClass()->name : $param->name;
var_dump($name);
}
}
Expected result:
----------------
DateTime: According to the docs, the names of the parameters should be "time" and
"timezone". The type-hints are also missing, for example "timezone" is a
"DateTimeZone".
ArrayObject: According to the docs, the names of the parameters should be "input",
"flags", and "iterator_class".
Actual result:
--------------
DateTime: Names of the parameters are "time" and "object", with no type-hints.
ArrayObject: Names of the parameters are "input", "ar_flags", and
"iterator_class"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76131&edit=1