Bug #76131 [NEW]: ReflectionParameter names and documentation variable names not matching up
| From: | timothy dot fisher at riosalado dot edu | Date: | Wed, 21 Mar 2018 22:47:14 +0000 |
| Subject: | Bug #76131 [NEW]: ReflectionParameter names and documentation variable names not matching up | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214439@lists.php.net to get a copy of this message | ||
From: timothy dot fisher at riosalado dot edu
Operating system:
PHP version: Irrelevant
Package: Reflection related
Bug Type: Bug
Bug description:ReflectionParameter names and documentation variable names not matching up
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 bug report at https://bugs.php.net/bug.php?id=76131&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76131&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76131&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76131&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76131&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76131&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76131&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76131&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76131&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76131&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76131&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76131&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76131&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76131&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76131&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76131&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76131&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76131&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76131&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76131&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76131&r=mysqlcfg