Bug #74706 [Com]: Invalid Reflection signatures for various methods, e.g. DateTime::__set_state
| From: | carusogabriel34 at gmail dot com | Date: | Wed, 07 Feb 2018 15:45:42 +0000 |
| Subject: | Bug #74706 [Com]: Invalid Reflection signatures for various methods, e.g. DateTime::__set_state | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213846@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74706&edit=1
ID: 74706
Comment by: carusogabriel34 at gmail dot com
Reported by: tandre at themeetgroup dot com
Summary: Invalid Reflection signatures for various methods,
e.g. DateTime::__set_state
Status: Open
Type: Bug
Package: Date/time related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This was fixed in https://github.com/php/php-src/pull/3038
Previous Comments:
------------------------------------------------------------------------
[2017-06-08 05:31:30] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74706&edit=1