summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-09-11 11:56:45 +0300
committerDmitry Stogov <dmitry@zend.com>2018-09-11 11:56:45 +0300
commit3a249e769b293afa454b18b8d894c3395683d26c (patch)
tree93d89c66728cb981136572bbc79e5a1ae756315a /ext/reflection/php_reflection.c
parentc4b14370cfc6884005d7976cf75af007e6f24e14 (diff)
downloadphp-git-3a249e769b293afa454b18b8d894c3395683d26c.tar.gz
Squashed commit of the following:
commit 2d3cac9e005d6bef9aa73ab57cc674aa53125954 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 11:54:47 2018 +0300 Fixed static property access commit 31786ee27282f319f3ef2a07635b1f325cbd67c6 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 11:05:29 2018 +0300 Avoid duplicate checks commit 5ae502b979ea33d058d01a9421eec5afd0084e8d Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 10:39:17 2018 +0300 Optimization commit 82c17f0e8af02c9cf7d1bbdae4e3158330148203 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 09:26:50 2018 +0300 Removed unused zend_duplicate_property_info() commit ba53d1d0dd91d5530328a11cac93ff9e75c462b5 Merge: eacc11b8fd c4b14370cf Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 09:24:13 2018 +0300 Merge branch 'master' into shadow * master: 7.0.33 next Sync NEWS [ci skip] add NEWS for 76582 Enforce ordering of property compare in object comparisons Fixed wrong assertion Skip test on unsuitable env commit eacc11b8fdeb002ee6a149defd8b5a8c3412896a Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 13:12:39 2018 +0300 Fixed failure of ext/spl/tests/array_017.phpt commit 62d1871430a1b81c84b790460afff0682648689a Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 11:55:07 2018 +0300 Fixed issues commit 1d37e3a40e4d07c4b933ed6f9d2e649dd01180f0 Merge: d6c3f098b6 1e550e6f7e Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 10:21:20 2018 +0300 Merge branch 'master' into shadow * master: Update NEWS Fix for bug #76582 Fix ssl stream reneg limit test to print only after first renegotiation Make a copy unconditionally Fix memory leak in pcre cache Remove not needed checking for <errno.h> Remove HAVE_ASSERT_H Add test for bug #76850 Fixed bug #76850 Exit code mangled by set locale/preg_match Remove empty PHP tags from test Fix #75273: php_zlib_inflate_filter() may not update bytes_consumed Fix PCRE2 exclusion and remove dead libs in Makefile.gcov Report mem leaks to stderr if no Win debugger is present Use combined assignment contanation operator Fixed bug #76796 Support fixed address mmap without replacement commit d6c3f098b6015e76d042691de0af2e1426c66829 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Sep 7 13:56:30 2018 +0300 Get rid of ZEND_ACC_SHADOW
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index eeb3ac66b8..fbacb9e92e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -366,7 +366,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if(prop->flags & ZEND_ACC_SHADOW) {
+ if ((prop->flags & ZEND_ACC_PRIVATE) && prop->ce != ce) {
count_shadow_props++;
} else if (prop->flags & ZEND_ACC_STATIC) {
count_static_props++;
@@ -380,7 +380,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) {
+ if ((prop->flags & ZEND_ACC_STATIC) && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
_property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
}
} ZEND_HASH_FOREACH_END();
@@ -427,7 +427,8 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) {
+ if (!(prop->flags & ZEND_ACC_STATIC)
+ && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
_property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
}
} ZEND_HASH_FOREACH_END();
@@ -1242,7 +1243,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name,
tmp_ce = tmp_ce->parent;
}
- if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */
+ if (tmp_info && (!(tmp_info->flags & ZEND_ACC_PRIVATE) || tmp_info->ce == tmp_ce)) { /* found something and it's not a parent's private */
prop = tmp_info;
} else { /* not found, use initial value */
ce = store_ce;
@@ -3764,9 +3765,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
zend_string *key;
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) {
- if (((prop_info->flags & ZEND_ACC_SHADOW) &&
- prop_info->ce != ce) ||
- ((prop_info->flags & ZEND_ACC_PROTECTED) &&
+ if (((prop_info->flags & ZEND_ACC_PROTECTED) &&
!zend_check_protected(prop_info->ce, ce)) ||
((prop_info->flags & ZEND_ACC_PRIVATE) &&
prop_info->ce != ce)) {
@@ -4220,7 +4219,7 @@ ZEND_METHOD(reflection_class, hasProperty)
GET_REFLECTION_OBJECT_PTR(ce);
if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
- if (property_info->flags & ZEND_ACC_SHADOW) {
+ if ((property_info->flags & ZEND_ACC_PRIVATE) && property_info->ce != ce) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -4255,7 +4254,7 @@ ZEND_METHOD(reflection_class, getProperty)
GET_REFLECTION_OBJECT_PTR(ce);
if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
- if ((property_info->flags & ZEND_ACC_SHADOW) == 0) {
+ if (!(property_info->flags & ZEND_ACC_PRIVATE) || property_info->ce == ce) {
reflection_property_factory(ce, name, property_info, return_value);
return;
}
@@ -4297,7 +4296,10 @@ ZEND_METHOD(reflection_class, getProperty)
}
ce = ce2;
- if ((property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len)) != NULL && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
+ property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len);
+ if (property_info != NULL
+ && (!(property_info->flags & ZEND_ACC_PRIVATE)
+ || property_info->ce == ce)) {
reflection_property_factory_str(ce, str_name, str_name_len, property_info, return_value);
return;
}
@@ -4316,7 +4318,7 @@ static int _addproperty(zval *el, int num_args, va_list args, zend_hash_key *has
zval *retval = va_arg(args, zval*);
long filter = va_arg(args, long);
- if (pptr->flags & ZEND_ACC_SHADOW) {
+ if ((pptr->flags & ZEND_ACC_PRIVATE) && pptr->ce != ce) {
return 0;
}
@@ -5278,7 +5280,10 @@ ZEND_METHOD(reflection_property, __construct)
/* returns out of this function */
}
- if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) == NULL || (property_info->flags & ZEND_ACC_SHADOW)) {
+ property_info = zend_hash_find_ptr(&ce->properties_info, name);
+ if (property_info == NULL
+ || ((property_info->flags & ZEND_ACC_PRIVATE)
+ && property_info->ce != ce)) {
/* Check for dynamic properties */
if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) {
if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) {
@@ -5530,7 +5535,7 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
ce = tmp_ce = ref->ce;
while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, ref->unmangled_name)) != NULL) {
- if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & ZEND_ACC_SHADOW) {
+ if (tmp_info->flags & ZEND_ACC_PRIVATE) {
/* it's a private property, so it can't be inherited */
break;
}