php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78897 ReflectionMethod::getClosure declaration changed silently in 7.4
Submitted: 2019-12-02 11:30 UTC Modified: 2019-12-04 07:10 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: dinchev dot dimitar at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Reflection related
PHP Version: 7.4.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dinchev dot dimitar at gmail dot com
New email:
PHP Version: OS:

 

 [2019-12-02 11:30 UTC] dinchev dot dimitar at gmail dot com
Description:
------------
Since upgrading to PHP 7.4, I get the following PHP Warning:
Declaration of Go\ParserReflection\ReflectionMethod::getClosure($object) should be compatible with ReflectionMethod::getClosure($object = NULL)

The above framework class is extending ReflectionMethod and until 7.3.x the declaration of ReflectionMethod::getClosure($object) apparently didn't have default null value, now making it incompatible with the subclass declaration.

The change is not reflected in the release notes of PHP 7.4.0 or in the current documentation:
https://www.php.net/manual/en/reflectionmethod.getclosure.php

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

class ReflectionMethodSubclass extends ReflectionMethod {
    public function getClosure($object) {
        return parent::getClosure($object);
    }
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-02 11:40 UTC] cmb@php.net
-Assigned To: +Assigned To: nikita
 [2019-12-02 11:40 UTC] cmb@php.net
This is caused by a fix[1] for static methods, which don't expect
an argument to be passed to ReflectionMethod::getClosure().

It seems to me that it's best to stick with this change, and to
document it.

Nikita, thoughts?

[1] <http://git.php.net/?p=php-src.git;a=commit;h=f085bddb51cf3ce4400f89447e40ddac66468f31>
 [2019-12-02 12:20 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=348397
Log: The signature of ReflectionMethod::getClosure() depends on its usage

As already pointed out in the description of the $object parameter.
See also bug #78897.
 [2019-12-03 19:46 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=348414
Log: The signature of ReflectionMethod::getClosure() depends on its usage

As already pointed out in the description of the $object parameter.
See also bug #78897.

Bug: https://bugs.php.net/78897 (Assigned) ReflectionMethod::getClosure declaration changed silently in 7.4
 [2019-12-04 06:12 UTC] nikic@php.net
-Assigned To: nikita +Assigned To: nikic
 [2019-12-04 06:12 UTC] nikic@php.net
Right, this change should stay, as the previous signature was outright wrong. With the documentation change done, anything else that needs to happen before this can be closed?
 [2019-12-04 07:10 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2019-12-04 07:10 UTC] nikic@php.net
UPGRADING note added in https://github.com/php/php-src/commit/9533a815d50df3f916b133ca7d9885c3d0d8ff92, so closing this now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 19:01:31 2024 UTC