php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74706 Invalid Reflection signatures for various methods, e.g. DateTime::__set_state
Submitted: 2017-06-08 05:31 UTC Modified: 2018-02-07 15:49 UTC
From: tandre at themeetgroup dot com Assigned: cmb (profile)
Status: Closed Package: Date/time 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: tandre at themeetgroup dot com
New email:
PHP Version: OS:

 

 [2017-06-08 05:31 UTC] tandre at themeetgroup dot com
Description:
------------


DateInterval::__set_state, DateTimeImmutable::__set_state, DateTime::__set_state, and DateTimeZone::__set_state all have getNumberOfParameters() == 0 for their ReflectionMethod instances

Additionally, the function 'datefmt_set_lenient' seems to have incorrect ReflectionFunction data: it says it has 1 required parameter, but should say 2 required parameters

Test script:
---------------
// https://3v4l.org/jEmee for the full test script

$classes = array('DateInterval', 'DateTimeImmutable', 'DateTime', 'DateTimeZone');
foreach ($classes as $class){ 
    echo "Signature of $class::_set_state\n";
    try{
        $rm = new ReflectionMethod($class, '__set_state');
        var_dump($rm->getNumberOfParameters());
        var_dump($rm->getNumberOfRequiredParameters());
    } catch(Exception $e) {
        echo "$class: " . $e;
    }
}

echo "End of param counts for __set_state\n\n";
var_export(DateTime::__set_state(array(
   'date' => '2017-06-08 05:11:40.907706',
   'timezone_type' => 3,
   'timezone' => 'UTC',
)));
//  DateTime::__set_state();  // would trigger Warning: DateTime::__set_state() expects exactly 1 parameter, 0 given in php shell code on line 1

// See 3v4l link for rest of script

Expected result:
----------------
Reflection counts should be 1 required, 1 total parameter for those __set_state functions.
ReflectionFunction for datefmt_set_lenient should have 2 required, 2 total parameters

Actual result:
--------------
Reflection counts say 0 required, 0 total parameter for those __set_state functions.
ReflectionFunction for datefmt_set_lenient currently shows 1 required, 1 total parameter

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-07 15:45 UTC] carusogabriel34 at gmail dot com
This was fixed in https://github.com/php/php-src/pull/3038
 [2018-02-07 15:49 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-02-07 15:49 UTC] cmb@php.net
Will be fixed in PHP 7.3.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC