Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #81200 ReflectionMethod::isStatic belongs on ReflectionFunctionAbstract #7196

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function isGenerator(): bool {}
/** @tentative-return-type */
public function isVariadic(): bool {}

/** @tentative-return-type */
public function isStatic(): bool {}

/** @tentative-return-type */
public function getClosureThis(): ?object {}

Expand Down Expand Up @@ -175,9 +178,6 @@ public function isAbstract(): bool {}
/** @tentative-return-type */
public function isFinal(): bool {}

/** @tentative-return-type */
public function isStatic(): bool {}

/** @tentative-return-type */
public function isConstructor(): bool {}

Expand Down
10 changes: 5 additions & 5 deletions ext/reflection/php_reflection_arginfo.h
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions ext/reflection/tests/closures_005.phpt
Original file line number Diff line number Diff line change
@@ -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(),
krakjoe marked this conversation as resolved.
Show resolved Hide resolved
(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)