Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c34558d

Browse files
GH-19691: Add asymmetric visibility to Reflection::getModifierNames() (#19697)
1 parent 01ae278 commit c34558d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

‎NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ PHP NEWS
3535
- PDO:
3636
. Driver specific methods in the PDO class are now deprecated. (Arnaud)
3737

38+
- Reflection:
39+
. Fix GH-19691 (getModifierNames() not reporting asymmetric visibility).
40+
(DanielEScherzer)
41+
3842
- Session:
3943
. Fix RC violation of session SID constant deprecation attribute. (ilutov)
4044

‎ext/reflection/php_reflection.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,15 @@ ZEND_METHOD(Reflection, getModifierNames)
17131713
add_next_index_stringl(return_value, "protected", sizeof("protected")-1);
17141714
break;
17151715
}
1716+
/* These are also mutually exclusive */
1717+
switch (modifiers & ZEND_ACC_PPP_SET_MASK) {
1718+
case ZEND_ACC_PROTECTED_SET:
1719+
add_next_index_stringl(return_value, "protected(set)", sizeof("protected(set)")-1);
1720+
break;
1721+
case ZEND_ACC_PRIVATE_SET:
1722+
add_next_index_stringl(return_value, "private(set)", sizeof("private(set)")-1);
1723+
break;
1724+
}
17161725

17171726
if (modifiers & ZEND_ACC_STATIC) {
17181727
add_next_index_str(return_value, ZSTR_KNOWN(ZEND_STR_STATIC));

‎ext/reflection/tests/Reflection_getModifierNames_001.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ printModifiers(ReflectionMethod::IS_ABSTRACT | ReflectionMethod::IS_FINAL);
1515
printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_STATIC | ReflectionProperty::IS_READONLY);
1616
printModifiers(ReflectionClass::IS_READONLY);
1717
printModifiers(ReflectionProperty::IS_VIRTUAL);
18+
printModifiers(ReflectionProperty::IS_PROTECTED_SET);
19+
printModifiers(ReflectionProperty::IS_PRIVATE_SET);
1820
?>
1921
--EXPECT--
2022
private
@@ -25,3 +27,5 @@ abstract,final
2527
public,static,readonly
2628
readonly
2729
virtual
30+
protected(set)
31+
private(set)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /