Fix bug #81200 ReflectionMethod::isStatic belongs on ReflectionFunctionAbstract

This commit is contained in:
Joe Watkins 2021-06-25 11:39:29 +02:00
parent 4957b7c02b
commit aad0d26816
No known key found for this signature in database
GPG Key ID: F9BA0ADA31CBD89E
5 changed files with 47 additions and 16 deletions

5
NEWS
View File

@ -2,9 +2,12 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.0alpha3
- Core
- Core:
. Fixed bug #81202 (powerpc64 build fails on fibers). (krakjoe)
- Reflection:
. Fixed bug #81200 (no way to determine if Closure is static). (krakjoe)
24 Jun 2021, PHP 8.1.0alpha2
- Core:

View File

@ -3398,13 +3398,6 @@ ZEND_METHOD(ReflectionMethod, isProtected)
}
/* }}} */
/* {{{ Returns whether this method is static */
ZEND_METHOD(ReflectionMethod, isStatic)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
}
/* }}} */
/* {{{ Returns whether this function is deprecated */
ZEND_METHOD(ReflectionFunctionAbstract, isDeprecated)
{
@ -3426,6 +3419,13 @@ ZEND_METHOD(ReflectionFunctionAbstract, isVariadic)
}
/* }}} */
/* {{{ Returns whether this function is static */
ZEND_METHOD(ReflectionFunctionAbstract, isStatic)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
}
/* }}} */
/* {{{ Returns whether this function is defined in namespace */
ZEND_METHOD(ReflectionFunctionAbstract, inNamespace)
{

View File

@ -44,6 +44,9 @@ abstract class ReflectionFunctionAbstract implements Reflector
/** @tentative-return-type */
public function isVariadic(): bool {}
/** @tentative-return-type */
public function isStatic(): bool {}
/** @tentative-return-type */
public function getClosureThis(): ?object {}
@ -175,9 +178,6 @@ class ReflectionMethod extends ReflectionFunctionAbstract
/** @tentative-return-type */
public function isFinal(): bool {}
/** @tentative-return-type */
public function isStatic(): bool {}
/** @tentative-return-type */
public function isConstructor(): bool {}

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: b7cb399903fb1965ba6294c4dcf9364539e93b5b */
* Stub hash: e66c459f457f71cb677a93652364ab7e81be8b0e */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
@ -23,6 +23,8 @@ ZEND_END_ARG_INFO()
#define arginfo_class_ReflectionFunctionAbstract_isVariadic arginfo_class_ReflectionFunctionAbstract_inNamespace
#define arginfo_class_ReflectionFunctionAbstract_isStatic arginfo_class_ReflectionFunctionAbstract_inNamespace
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFunctionAbstract_getClosureThis, 0, 0, IS_OBJECT, 1)
ZEND_END_ARG_INFO()
@ -139,8 +141,6 @@ ZEND_END_ARG_INFO()
#define arginfo_class_ReflectionMethod_isFinal arginfo_class_ReflectionFunctionAbstract_inNamespace
#define arginfo_class_ReflectionMethod_isStatic arginfo_class_ReflectionFunctionAbstract_inNamespace
#define arginfo_class_ReflectionMethod_isConstructor arginfo_class_ReflectionFunctionAbstract_inNamespace
#define arginfo_class_ReflectionMethod_isDestructor arginfo_class_ReflectionFunctionAbstract_inNamespace
@ -600,6 +600,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, isInternal);
ZEND_METHOD(ReflectionFunctionAbstract, isUserDefined);
ZEND_METHOD(ReflectionFunctionAbstract, isGenerator);
ZEND_METHOD(ReflectionFunctionAbstract, isVariadic);
ZEND_METHOD(ReflectionFunctionAbstract, isStatic);
ZEND_METHOD(ReflectionFunctionAbstract, getClosureThis);
ZEND_METHOD(ReflectionFunctionAbstract, getClosureScopeClass);
ZEND_METHOD(ReflectionFunctionAbstract, getClosureUsedVariables);
@ -642,7 +643,6 @@ ZEND_METHOD(ReflectionMethod, isPrivate);
ZEND_METHOD(ReflectionMethod, isProtected);
ZEND_METHOD(ReflectionMethod, isAbstract);
ZEND_METHOD(ReflectionMethod, isFinal);
ZEND_METHOD(ReflectionMethod, isStatic);
ZEND_METHOD(ReflectionMethod, isConstructor);
ZEND_METHOD(ReflectionMethod, isDestructor);
ZEND_METHOD(ReflectionMethod, getClosure);
@ -839,6 +839,7 @@ static const zend_function_entry class_ReflectionFunctionAbstract_methods[] = {
ZEND_ME(ReflectionFunctionAbstract, isUserDefined, arginfo_class_ReflectionFunctionAbstract_isUserDefined, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, isGenerator, arginfo_class_ReflectionFunctionAbstract_isGenerator, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, isVariadic, arginfo_class_ReflectionFunctionAbstract_isVariadic, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, isStatic, arginfo_class_ReflectionFunctionAbstract_isStatic, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, getClosureThis, arginfo_class_ReflectionFunctionAbstract_getClosureThis, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, getClosureScopeClass, arginfo_class_ReflectionFunctionAbstract_getClosureScopeClass, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionFunctionAbstract, getClosureUsedVariables, arginfo_class_ReflectionFunctionAbstract_getClosureUsedVariables, ZEND_ACC_PUBLIC)
@ -896,7 +897,6 @@ static const zend_function_entry class_ReflectionMethod_methods[] = {
ZEND_ME(ReflectionMethod, isProtected, arginfo_class_ReflectionMethod_isProtected, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, isAbstract, arginfo_class_ReflectionMethod_isAbstract, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, isFinal, arginfo_class_ReflectionMethod_isFinal, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, isStatic, arginfo_class_ReflectionMethod_isStatic, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, isConstructor, arginfo_class_ReflectionMethod_isConstructor, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, isDestructor, arginfo_class_ReflectionMethod_isDestructor, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionMethod, getClosure, arginfo_class_ReflectionMethod_getClosure, ZEND_ACC_PUBLIC)

View File

@ -0,0 +1,28 @@
--TEST--
Test closure isStatic
--FILE--
<?php
class Foo {
public static function bar(){}
public function baz() {}
public function qux() {
return static function(){};
}
}
$foo = new Foo;
var_dump(
(new ReflectionFunction(function(){}))->isStatic(),
(new ReflectionFunction(static function(){}))->isStatic(),
(new ReflectionFunction($foo->qux()))->isStatic(),
(new ReflectionMethod($foo, 'bar'))->isStatic(),
(new ReflectionMethod($foo, 'baz'))->isStatic(),);
?>
--EXPECT--
bool(false)
bool(true)
bool(true)
bool(true)
bool(false)