php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76131 ReflectionParameter names and documentation variable names not matching up
Submitted: 2018-03-21 22:47 UTC Modified: 2018-03-24 13:12 UTC
From: timothy dot fisher at riosalado dot edu Assigned:
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: timothy dot fisher at riosalado dot edu
New email:
PHP Version: OS:

 

 [2018-03-21 22:47 UTC] 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"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-27 20:01 UTC] krakjoe@php.net
Automatic comment on behalf of carusogabriel34@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=63934ea71e719cfc43e94167474f936d8da938de
Log: Fix #76131 some arginfo params are different from the documentation
 [2018-03-27 20:01 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC