diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-24 10:07:24 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-24 10:08:51 +0200 |
commit | 1dfeb70e6be3225a1ad0d17b991c23fa81405583 (patch) | |
tree | 1f092cbfa165812550bd9de169a5b112d099f254 /ext/reflection/php_reflection.c | |
parent | c9b9f525a929158736977d6bad938380cad29cc6 (diff) | |
parent | ef2130db88e3a1038c485eea9708cb2677dc9adc (diff) | |
download | php-git-1dfeb70e6be3225a1ad0d17b991c23fa81405583.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix #79487: ::getStaticProperties() ignores property modifications
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0a116a0127..2208b76aa9 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3845,9 +3845,7 @@ static void add_class_vars(zend_class_entry *ce, zend_bool statics, zval *return zend_string *key; ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) { - if (((prop_info->flags & ZEND_ACC_PROTECTED) && - !zend_check_protected(prop_info->ce, ce)) || - ((prop_info->flags & ZEND_ACC_PRIVATE) && + if (((prop_info->flags & ZEND_ACC_PRIVATE) && prop_info->ce != ce)) { continue; } @@ -3885,6 +3883,9 @@ ZEND_METHOD(ReflectionClass, getStaticProperties) { reflection_object *intern; zend_class_entry *ce; + zend_property_info *prop_info; + zval *prop; + zend_string *key; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -3896,8 +3897,34 @@ ZEND_METHOD(ReflectionClass, getStaticProperties) return; } + if (ce->default_static_members_count && !CE_STATIC_MEMBERS(ce)) { + zend_class_init_statics(ce); + } + array_init(return_value); - add_class_vars(ce, 1, return_value); + + ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) { + if (((prop_info->flags & ZEND_ACC_PRIVATE) && + prop_info->ce != ce)) { + continue; + } + if ((prop_info->flags & ZEND_ACC_STATIC) == 0) { + continue; + } + + prop = &CE_STATIC_MEMBERS(ce)[prop_info->offset]; + ZVAL_DEINDIRECT(prop); + + if (ZEND_TYPE_IS_SET(prop_info->type) && Z_ISUNDEF_P(prop)) { + continue; + } + + /* enforce read only access */ + ZVAL_DEREF(prop); + Z_TRY_ADDREF_P(prop); + + zend_hash_update(Z_ARRVAL_P(return_value), key, prop); + } ZEND_HASH_FOREACH_END(); } /* }}} */ |