Skip to content

Commit 5295e36

Browse files
committed
Filter return value of ReflectionClassConstant::getModifiers()
Don't return internal flags like IS_CASE.
1 parent fd1d5ec commit 5295e36

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3702,7 +3702,7 @@ ZEND_METHOD(ReflectionClassConstant, getModifiers)
37023702
}
37033703
GET_REFLECTION_OBJECT_PTR(ref);
37043704

3705-
RETURN_LONG(ZEND_CLASS_CONST_FLAGS(ref));
3705+
RETURN_LONG(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_ACC_PPP_MASK);
37063706
}
37073707
/* }}} */
37083708

ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ enum Foo {
88
const Baz = self::Bar;
99
}
1010

11-
echo (new ReflectionEnumUnitCase(Foo::class, 'Bar'))->getName() . "\n";
11+
$case = new ReflectionEnumUnitCase(Foo::class, 'Bar');
12+
var_dump($case->getName());
13+
var_dump($case->isPublic());
14+
var_dump($case->getModifiers());
1215

1316
try {
1417
new ReflectionEnumUnitCase(Foo::class, 'Baz');
@@ -30,7 +33,9 @@ try {
3033

3134
?>
3235
--EXPECT--
33-
Bar
36+
string(3) "Bar"
37+
bool(true)
38+
int(1)
3439
Constant Foo::Baz is not a case
3540
Constant Foo::Qux does not exist
3641
ReflectionEnumUnitCase::__construct(): Argument #1 ($class) must be of type object|string, array given

0 commit comments

Comments
 (0)