php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80299 ReflectionFunction->invokeArgs confused in arguments
Submitted: 2020-10-30 16:15 UTC Modified: 2020-10-30 16:21 UTC
From: roxblnfk at yandex dot com Assigned: nikic (profile)
Status: Closed Package: Reflection related
PHP Version: 8.0.0RC3 OS: php:8.0-rc-cli-alpine
Private report: No CVE-ID: None
 [2020-10-30 16:15 UTC] roxblnfk at yandex dot com
Description:
------------
Something goes wrong after generating a warning in the ReflectionFunction->invokeArgs() method. A Fatal error is thrown right after the Warning.

Docker image php:8.0-rc-cli-alpine
PHP 8.0.0RC3 (cli) (built: Oct 29 2020 21:50:53) ( NTS )

Test script:
---------------
<?php

$bar = new DateTime();
$args = [1, &$bar];

$function = function (int &$foo, DateTimeInterface &$bar) {};

(new ReflectionFunction($function))->invokeArgs($args);

Expected result:
----------------
Warning: {closure}(): Argument #1 ($foo) must be passed by reference, value given in /app/test.php on line 9

Actual result:
--------------
Warning: {closure}(): Argument #1 ($foo) must be passed by reference, value given in /app/test.php on line 9

Fatal error: Uncaught TypeError: {closure}(): Argument #2 ($bar) must be of type DateTimeInterface, number given in /app/test.php:6
Stack trace:
#0 [internal function]: {closure}(1, Object(DateTime))
#1 /app/test.php(9): ReflectionFunction->invokeArgs(Array)
#2 {main}
  thrown in /app/test.php on line 6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-30 16:17 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-10-30 16:21 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-10-30 16:24 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=904c1b6589b999a8e387215ac3c8fce9e4ab62a8
Log: FIxed bug #80299
 [2020-10-30 16:24 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC