Skip to content

Commit a673e18

Browse files
committed
Added ReflectionClass::isStatic and accompanying test.
1 parent c5cc53a commit a673e18

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5019,6 +5019,12 @@ ZEND_METHOD(ReflectionClass, isReadOnly)
50195019
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_READONLY_CLASS);
50205020
}
50215021

5022+
/* Returns whether this class is static */
5023+
ZEND_METHOD(ReflectionClass, isStatic)
5024+
{
5025+
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
5026+
}
5027+
50225028
/* {{{ Returns whether this class is abstract */
50235029
ZEND_METHOD(ReflectionClass, isAbstract)
50245030
{

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)