Skip to content

Commit 15539e0

Browse files
committed
Added ReflectionClass::isStatic and accompanying test.
1 parent c7824ae commit 15539e0

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

ext/reflection/php_reflection.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5018,6 +5018,12 @@ ZEND_METHOD(ReflectionClass, isReadOnly)
50185018
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_READONLY_CLASS);
50195019
}
50205020

5021+
/* Returns whether this class is static */
5022+
ZEND_METHOD(ReflectionClass, isStatic)
5023+
{
5024+
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
5025+
}
5026+
50215027
/* {{{ Returns whether this class is abstract */
50225028
ZEND_METHOD(ReflectionClass, isAbstract)
50235029
{
@@ -5030,7 +5036,7 @@ ZEND_METHOD(ReflectionClass, getModifiers)
50305036
{
50315037
reflection_object *intern;
50325038
zend_class_entry *ce;
5033-
uint32_t keep_flags = ZEND_ACC_STATIC| ZEND_ACC_FINAL | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_READONLY_CLASS;
5039+
uint32_t keep_flags = ZEND_ACC_STATIC | ZEND_ACC_FINAL | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_READONLY_CLASS;
50345040

50355041
if (zend_parse_parameters_none() == FAILURE) {
50365042
RETURN_THROWS();

ext/reflection/php_reflection.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ public function isFinal(): bool {}
357357

358358
public function isReadOnly(): bool {}
359359

360+
public function isStatic(): bool {}
361+
360362
/** @tentative-return-type */
361363
public function getModifiers(): int {}
362364

ext/reflection/php_reflection_arginfo.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Testing ReflectionClass::isStatic()
3+
--FILE--
4+
<?php
5+
6+
class C {}
7+
static class C2 {}
8+
9+
var_dump(new ReflectionClass('C')->isStatic());
10+
var_dump(new ReflectionClass('C2')->isStatic());
11+
?>
12+
--EXPECT--
13+
bool(false)
14+
bool(true)

0 commit comments

Comments
 (0)