|
58 | 58 | called, we cal __call handler. |
59 | 59 | */ |
60 | 60 |
|
| 61 | +ZEND_API zend_property_info **zend_build_properties_info_table(zend_class_entry *ce) |
| 62 | +{ |
| 63 | + zend_property_info *prop; |
| 64 | + zend_property_info **table = pemalloc( |
| 65 | + sizeof(zend_property_info *) * ce->default_properties_count, |
| 66 | + ce->type == ZEND_INTERNAL_CLASS |
| 67 | + ); |
| 68 | + |
| 69 | + ZEND_ASSERT(ce->properties_info_table == NULL); |
| 70 | + ZEND_ASSERT(ce->default_properties_count != 0); |
| 71 | + ce->properties_info_table = table; |
| 72 | + |
| 73 | + if (ce->parent && ce->parent->default_properties_count != 0) { |
| 74 | + zend_property_info **parent_table = zend_get_properties_info_table(ce->parent); |
| 75 | + memcpy( |
| 76 | + table, parent_table, |
| 77 | + sizeof(zend_property_info *) * ce->parent->default_properties_count |
| 78 | + ); |
| 79 | + |
| 80 | + /* Child did not add any new properties, we are done */ |
| 81 | + if (ce->default_properties_count == ce->parent->default_properties_count) { |
| 82 | + return table; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { |
| 87 | + if (prop->ce == ce && (prop->flags & ZEND_ACC_STATIC) == 0) { |
| 88 | + table[OBJ_PROP_TO_NUM(prop->offset)] = prop; |
| 89 | + } |
| 90 | + } ZEND_HASH_FOREACH_END(); |
| 91 | + return table; |
| 92 | +} |
| 93 | + |
61 | 94 | ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ |
62 | 95 | { |
63 | 96 | if (!zobj->properties) { |
@@ -573,6 +606,32 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf |
573 | 606 | } |
574 | 607 | /* }}} */ |
575 | 608 |
|
| 609 | +ZEND_API int zend_check_property_info_access(zend_property_info *prop_info) /* {{{ */ |
| 610 | +{ |
| 611 | + zend_class_entry *scope; |
| 612 | + if (prop_info->flags & ZEND_ACC_PUBLIC) { |
| 613 | + return SUCCESS; |
| 614 | + } |
| 615 | + |
| 616 | + if (UNEXPECTED(EG(fake_scope))) { |
| 617 | + scope = EG(fake_scope); |
| 618 | + } else { |
| 619 | + scope = zend_get_executed_scope(); |
| 620 | + } |
| 621 | + |
| 622 | + if (prop_info->ce == scope) { |
| 623 | + return SUCCESS; |
| 624 | + } |
| 625 | + |
| 626 | + if ((prop_info->flags & ZEND_ACC_PROTECTED) |
| 627 | + && is_protected_compatible_scope(prop_info->ce, scope)) { |
| 628 | + return SUCCESS; |
| 629 | + } |
| 630 | + |
| 631 | + return FAILURE; |
| 632 | +} |
| 633 | +/* }}} */ |
| 634 | + |
576 | 635 | static void zend_property_guard_dtor(zval *el) /* {{{ */ { |
577 | 636 | uint32_t *ptr = (uint32_t*)Z_PTR_P(el); |
578 | 637 | if (EXPECTED(!(((zend_uintptr_t)ptr) & 1))) { |
|
0 commit comments