diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-23 18:52:16 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-23 18:52:16 +0200 |
commit | f1d0eadc4d7c582a8bff77c16d04849c8ec7e8cf (patch) | |
tree | b2f36cebdd88978ccca75fe8a6ab0d2258428d62 /ext/reflection/php_reflection.c | |
parent | f3b1f342c887073012f4ca7c1bc1b5259ce4cedc (diff) | |
parent | a895bb6885fbceea3e8375816969d5510d8d082e (diff) | |
download | php-git-f1d0eadc4d7c582a8bff77c16d04849c8ec7e8cf.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..b88712b7b5 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_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 (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(); } /* }}} */ |