diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 82d47e320b3..0c22bcaaed2 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1595,6 +1595,9 @@ ZEND_METHOD(Reflection, getModifierNames) if (modifiers & ZEND_ACC_FINAL) { add_next_index_stringl(return_value, "final", sizeof("final")-1); } + if (modifiers & ZEND_ACC_VIRTUAL) { + add_next_index_stringl(return_value, "virtual", sizeof("virtual")-1); + } /* These are mutually exclusive */ switch (modifiers & ZEND_ACC_PPP_MASK) { diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index addba0e155c..d9acc08d224 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -464,6 +464,8 @@ class ReflectionProperty implements Reflector public const int IS_PROTECTED_SET = UNKNOWN; /** @cvalue ZEND_ACC_PRIVATE_SET */ public const int IS_PRIVATE_SET = UNKNOWN; + /** @cvalue ZEND_ACC_VIRTUAL */ + public const int IS_VIRTUAL = UNKNOWN; /** @cvalue ZEND_ACC_FINAL */ public const int IS_FINAL = UNKNOWN; diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index 3fb938783f6..92d80de5a60 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ad354b7dc9caadc2bb5ed810964ebf83acd27f1d */ + * Stub hash: 1cdf310b94e2297a4e426bd4c0c1ab4d5995936d */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0) @@ -1605,6 +1605,12 @@ static zend_class_entry *register_class_ReflectionProperty(zend_class_entry *cla zend_declare_typed_class_constant(class_entry, const_IS_PRIVATE_SET_name, &const_IS_PRIVATE_SET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_IS_PRIVATE_SET_name); + zval const_IS_VIRTUAL_value; + ZVAL_LONG(&const_IS_VIRTUAL_value, ZEND_ACC_VIRTUAL); + zend_string *const_IS_VIRTUAL_name = zend_string_init_interned("IS_VIRTUAL", sizeof("IS_VIRTUAL") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_IS_VIRTUAL_name, &const_IS_VIRTUAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_IS_VIRTUAL_name); + zval const_IS_FINAL_value; ZVAL_LONG(&const_IS_FINAL_value, ZEND_ACC_FINAL); zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, 1); diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt index 63d5d476b4d..edb6adc0b6b 100644 --- a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt @@ -14,12 +14,15 @@ class C { static public $pubs2; static private $privs1; static private $privs2; + public $hookNoVirt { set { $this->hookNoVirt = strtoupper($value); } } + public $hookVirt { get { return 42; } } } $rc = new ReflectionClass("C"); $StaticFlag = ReflectionProperty::IS_STATIC; $pubFlag = ReflectionProperty::IS_PUBLIC; $privFlag = ReflectionProperty::IS_PRIVATE; +$virtFlag = ReflectionProperty::IS_VIRTUAL; echo "No properties:"; var_dump($rc->getProperties(0)); @@ -35,11 +38,14 @@ var_dump($rc->getProperties($StaticFlag | $pubFlag)); echo "Private or static properties:"; var_dump($rc->getProperties($StaticFlag | $privFlag)); + +echo "Virtual properties:"; +var_dump($rc->getProperties($virtFlag)); ?> --EXPECTF-- No properties:array(0) { } -Public properties:array(4) { +Public properties:array(6) { [0]=> object(ReflectionProperty)#%d (2) { ["name"]=> @@ -68,6 +74,20 @@ Public properties:array(4) { ["class"]=> string(1) "C" } + [4]=> + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(10) "hookNoVirt" + ["class"]=> + string(1) "C" + } + [5]=> + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(8) "hookVirt" + ["class"]=> + string(1) "C" + } } Private properties:array(4) { [0]=> @@ -99,7 +119,7 @@ Private properties:array(4) { string(1) "C" } } -Public or static properties:array(6) { +Public or static properties:array(8) { [0]=> object(ReflectionProperty)#%d (2) { ["name"]=> @@ -142,6 +162,20 @@ Public or static properties:array(6) { ["class"]=> string(1) "C" } + [6]=> + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(10) "hookNoVirt" + ["class"]=> + string(1) "C" + } + [7]=> + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(8) "hookVirt" + ["class"]=> + string(1) "C" + } } Private or static properties:array(6) { [0]=> @@ -187,3 +221,12 @@ Private or static properties:array(6) { string(1) "C" } } +Virtual properties:array(1) { + [0]=> + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(8) "hookVirt" + ["class"]=> + string(1) "C" + } +} diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt index c59c3fc75f2..e2818bf0c2c 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt @@ -12,6 +12,8 @@ class C { static private $a6; public final $a7; public static final $a8; + public $a9 { set { $this->a9 = strtoupper($value); } } + public $a10 { get { return 42; } } } class D extends C { @@ -23,7 +25,7 @@ class D extends C { static private $a6; } -for ($i = 1;$i <= 8;$i++) { +for ($i = 1;$i <= 10;$i++) { $rp = new ReflectionProperty("C", "a$i"); echo "C::a$i: "; var_dump($rp->getModifiers()); @@ -50,3 +52,7 @@ C::a7: int(33) D::a7: int(33) C::a8: int(49) D::a8: int(49) +C::a9: int(1) +D::a9: int(1) +C::a10: int(513) +D::a10: int(513) diff --git a/ext/reflection/tests/Reflection_getModifierNames_001.phpt b/ext/reflection/tests/Reflection_getModifierNames_001.phpt index e095e95995d..918ef2f2800 100644 --- a/ext/reflection/tests/Reflection_getModifierNames_001.phpt +++ b/ext/reflection/tests/Reflection_getModifierNames_001.phpt @@ -14,6 +14,7 @@ printModifiers(ReflectionClass::IS_EXPLICIT_ABSTRACT); printModifiers(ReflectionMethod::IS_ABSTRACT | ReflectionMethod::IS_FINAL); printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_STATIC | ReflectionProperty::IS_READONLY); printModifiers(ReflectionClass::IS_READONLY); +printModifiers(ReflectionProperty::IS_VIRTUAL); ?> --EXPECT-- private @@ -23,3 +24,4 @@ abstract abstract,final public,static,readonly readonly +virtual