Bug #78897 [Asn]: ReflectionMethod::getClosure declaration changed silently in 7.4

From: Date: Wed, 04 Dec 2019 06:12:30 +0000
Subject: Bug #78897 [Asn]: ReflectionMethod::getClosure declaration changed silently in 7.4
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224036@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78897&edit=1 ID: 78897 Updated by: nikic@php.net Reported by: dinchev dot dimitar at gmail dot com Summary: ReflectionMethod::getClosure declaration changed silently in 7.4 Status: Assigned Type: Bug Package: Reflection related Operating System: Linux PHP Version: 7.4.0 -Assigned To: nikita +Assigned To: nikic Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2019-12-03 19:46:52] 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-02 12:20:39] 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-02 11:40:20] 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 11:30:35] 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); } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78897&edit=1

« previous php.bugs (#224036) next »