Skip to content

Commit

Permalink
Fixed bug phpGH-8943 Reflection::getModifiersNames() with readonly mo…
Browse files Browse the repository at this point in the history
…difier
  • Loading branch information
adoy committed Jul 7, 2022
1 parent de202a5 commit c650e67
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,10 @@ ZEND_METHOD(Reflection, getModifierNames)
if (modifiers & ZEND_ACC_STATIC) {
add_next_index_stringl(return_value, "static", sizeof("static")-1);
}

if (modifiers & ZEND_ACC_READONLY) {
add_next_index_stringl(return_value, "readonly", sizeof("readonly")-1);
}
}
/* }}} */

Expand Down
23 changes: 23 additions & 0 deletions ext/reflection/tests/Reflection_getModifierNames_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Reflection::getModifierNames() basic
--FILE--
<?php

function printModifiers($modifiers) {
echo implode(',', Reflection::getModifierNames($modifiers)), PHP_EOL;
}

printModifiers(ReflectionProperty::IS_PRIVATE);
printModifiers(ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_STATIC);
printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_READONLY);
printModifiers(ReflectionClass::IS_EXPLICIT_ABSTRACT);
printModifiers(ReflectionMethod::IS_ABSTRACT | ReflectionMethod::IS_FINAL);
printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_STATIC | ReflectionProperty::IS_READONLY);
?>
--EXPECT--
private
protected,static
public,readonly
abstract
abstract,final
public,static,readonly

0 comments on commit c650e67

Please sign in to comment.