Lines Matching refs:ce

34 ZEND_API zend_class_entry* (*zend_inheritance_cache_get)(zend_class_entry *ce, zend_class_entry *pa…
35 ZEND_API zend_class_entry* (*zend_inheritance_cache_add)(zend_class_entry *ce, zend_class_entry *pr…
48 static void add_dependency_obligation(zend_class_entry *ce, zend_class_entry *dependency_ce);
50 zend_class_entry *ce, const zend_function *child_fn, zend_class_entry *child_scope,
53 zend_class_entry *ce, const zend_property_info *child_prop,
56 zend_class_entry *ce, const zend_class_constant *child_const,
59 zend_class_entry *ce, const zend_property_info *hooked_prop, const zend_function *hook_func);
98 …nction *zend_duplicate_internal_function(zend_function *func, const zend_class_entry *ce) /* {{{ */ in zend_duplicate_internal_function() argument
102 if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) { in zend_duplicate_internal_function()
117 …e zend_function *zend_duplicate_function(zend_function *func, const zend_class_entry *ce) /* {{{ */ in zend_duplicate_function() argument
120 return zend_duplicate_internal_function(func, ce); in zend_duplicate_function()
133 static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ in do_inherit_parent_constructor() argument
135 zend_class_entry *parent = ce->parent; in do_inherit_parent_constructor()
140 ce->create_object = parent->create_object; in do_inherit_parent_constructor()
143 if (EXPECTED(!ce->get_iterator)) { in do_inherit_parent_constructor()
144 ce->get_iterator = parent->get_iterator; in do_inherit_parent_constructor()
146 if (EXPECTED(!ce->__get)) { in do_inherit_parent_constructor()
147 ce->__get = parent->__get; in do_inherit_parent_constructor()
149 if (EXPECTED(!ce->__set)) { in do_inherit_parent_constructor()
150 ce->__set = parent->__set; in do_inherit_parent_constructor()
152 if (EXPECTED(!ce->__unset)) { in do_inherit_parent_constructor()
153 ce->__unset = parent->__unset; in do_inherit_parent_constructor()
155 if (EXPECTED(!ce->__isset)) { in do_inherit_parent_constructor()
156 ce->__isset = parent->__isset; in do_inherit_parent_constructor()
158 if (EXPECTED(!ce->__call)) { in do_inherit_parent_constructor()
159 ce->__call = parent->__call; in do_inherit_parent_constructor()
161 if (EXPECTED(!ce->__callstatic)) { in do_inherit_parent_constructor()
162 ce->__callstatic = parent->__callstatic; in do_inherit_parent_constructor()
164 if (EXPECTED(!ce->__tostring)) { in do_inherit_parent_constructor()
165 ce->__tostring = parent->__tostring; in do_inherit_parent_constructor()
167 if (EXPECTED(!ce->clone)) { in do_inherit_parent_constructor()
168 ce->clone = parent->clone; in do_inherit_parent_constructor()
170 if (EXPECTED(!ce->__serialize)) { in do_inherit_parent_constructor()
171 ce->__serialize = parent->__serialize; in do_inherit_parent_constructor()
173 if (EXPECTED(!ce->__unserialize)) { in do_inherit_parent_constructor()
174 ce->__unserialize = parent->__unserialize; in do_inherit_parent_constructor()
176 if (EXPECTED(!ce->serialize)) { in do_inherit_parent_constructor()
177 ce->serialize = parent->serialize; in do_inherit_parent_constructor()
179 if (EXPECTED(!ce->unserialize)) { in do_inherit_parent_constructor()
180 ce->unserialize = parent->unserialize; in do_inherit_parent_constructor()
182 if (!ce->destructor) { in do_inherit_parent_constructor()
183 ce->destructor = parent->destructor; in do_inherit_parent_constructor()
185 if (EXPECTED(!ce->__debugInfo)) { in do_inherit_parent_constructor()
186 ce->__debugInfo = parent->__debugInfo; in do_inherit_parent_constructor()
189 if (ce->constructor) { in do_inherit_parent_constructor()
193 ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name)); in do_inherit_parent_constructor()
198 ce->constructor = parent->constructor; in do_inherit_parent_constructor()
242 static bool class_visible(const zend_class_entry *ce) { in class_visible() argument
243 if (ce->type == ZEND_INTERNAL_CLASS) { in class_visible()
246 ZEND_ASSERT(ce->type == ZEND_USER_CLASS); in class_visible()
248 || ce->info.user.filename == CG(compiled_filename); in class_visible()
263 zend_class_entry *ce; in lookup_class_ex() local
269 ce = zend_hash_find_ptr(CG(class_table), lc_name); in lookup_class_ex()
273 if (register_unresolved && !ce) { in lookup_class_ex()
279 return ce; in lookup_class_ex()
282 ce = zend_lookup_class_ex( in lookup_class_ex()
286 if (ce) { in lookup_class_ex()
287 return ce; in lookup_class_ex()
294 if (ce && class_visible(ce)) { in lookup_class_ex()
295 return ce; in lookup_class_ex()
349 zend_class_entry *ce = zend_lookup_class_ex( in unlinked_instanceof() local
353 if (ce && ce != ce1 && unlinked_instanceof(ce, ce2)) { in unlinked_instanceof()
376 zend_class_entry *ce = lookup_class(self, name); in zend_type_permits_self() local
377 if (ce && unlinked_instanceof(self, ce)) { in zend_type_permits_self()
385 static void track_class_dependency(zend_class_entry *ce, zend_string *class_name) in track_class_dependency() argument
390 if (!CG(current_linking_class) || ce == CG(current_linking_class)) { in track_class_dependency()
400 if (ce->type == ZEND_INTERNAL_CLASS) { in track_class_dependency()
407 if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) { in track_class_dependency()
425 zend_hash_add_ptr(ht, class_name, ce); in track_class_dependency()
1080 zend_class_entry *ce, in perform_delayable_implementation_check() argument
1088 add_compatibility_obligation(ce, fe, fe_scope, proto, proto_scope); in perform_delayable_implementation_check()
1107 zend_class_entry *ce, zval *child_zv, uint32_t flags) /* {{{ */ in do_inheritance_check_on_method() argument
1115 && child_scope != ce && child->type == ZEND_USER_FUNCTION) { \ in do_inheritance_check_on_method()
1211 perform_delayable_implementation_check(ce, child, child_scope, parent, parent_scope); in do_inheritance_check_on_method()
1226 static void do_inherit_method(zend_string *key, zend_function *parent, zend_class_entry *ce, bool i… in do_inherit_method() argument
1228 zval *child = zend_hash_find_known_hash(&ce->function_table, key); in do_inherit_method()
1239 func, func->common.scope, parent, parent->common.scope, ce, child, flags); in do_inherit_method()
1243 ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; in do_inherit_method()
1246 parent = zend_duplicate_function(parent, ce); in do_inherit_method()
1249 _zend_hash_append_ptr(&ce->function_table, key, parent); in do_inherit_method()
1251 zend_hash_add_new_ptr(&ce->function_table, key, parent); in do_inherit_method()
1272 child_info->ce, child_info->type, parent_info->ce, parent_info->type); in full_property_types_compatible()
1275 parent_info->ce, parent_info->type, child_info->ce, child_info->type); in full_property_types_compatible()
1288 zend_string *type_str = zend_type_to_string_resolved(parent->type, parent->ce); in emit_incompatible_property_error()
1291 ZSTR_VAL(child->ce->name), in emit_incompatible_property_error()
1296 ZSTR_VAL(parent->ce->name)); in emit_incompatible_property_error()
1302 zend_string *type_str = zend_type_to_string_resolved(set_type, parent->ce); in emit_set_hook_type_error()
1305 ZSTR_VAL(child->ce->name), in emit_set_hook_type_error()
1308 zend_get_object_type_case(parent->ce, false), in emit_set_hook_type_error()
1309 ZSTR_VAL(parent->ce->name)); in emit_set_hook_type_error()
1332 parent_info->ce, set_type, child_info->ce, child_info->type); in verify_property_type_compatibility()
1349 zend_class_entry *ce, in inherit_property_hook() argument
1373 ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; in inherit_property_hook()
1376 ce->num_hooked_props++; in inherit_property_hook()
1380 child_info->hooks[kind] = zend_duplicate_function(parent, ce); in inherit_property_hook()
1400 child, child->common.scope, parent, parent->common.scope, ce, /* child */ NULL, in inherit_property_hook()
1423 …inherit_property(zend_property_info *parent_info, zend_string *key, zend_class_entry *ce) /* {{{ */ in do_inherit_property() argument
1425 zval *child = zend_hash_find_known_hash(&ce->properties_info, key); in do_inherit_property()
1435 ZSTR_VAL(parent_info->ce->name), ZSTR_VAL(key)); in do_inherit_property()
1438 if (!(parent_info->ce->ce_flags & ZEND_ACC_INTERFACE)) { in do_inherit_property()
1444 …(parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(parent_info->ce->name… in do_inherit_property()
1445 …(child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(ce->name), ZSTR_VAL(ke… in do_inherit_property()
1452 ZSTR_VAL(parent_info->ce->name), ZSTR_VAL(key), in do_inherit_property()
1454 ZSTR_VAL(ce->name), ZSTR_VAL(key)); in do_inherit_property()
1471 ZSTR_VAL(ce->name), ZSTR_VAL(key), in do_inherit_property()
1472 zend_asymmetric_visibility_string(parent_info->flags), ZSTR_VAL(parent_info->ce->name), in do_inherit_property()
1478 …as in class %s)%s", ZSTR_VAL(ce->name), ZSTR_VAL(key), zend_visibility_string(parent_info->flags),… in do_inherit_property()
1486 zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num])); in do_inherit_property()
1487 ce->default_properties_table[parent_num] = ce->default_properties_table[child_num]; in do_inherit_property()
1488 ZVAL_UNDEF(&ce->default_properties_table[child_num]); in do_inherit_property()
1497 inherit_property_hook(ce, parent_info, child_info, i); in do_inherit_property()
1506 add_property_compatibility_obligation(ce, child_info, parent_info, variance); in do_inherit_property()
1511 ZSTR_VAL(ce->name), in do_inherit_property()
1513 ZSTR_VAL(parent_info->ce->name)); in do_inherit_property()
1519 ce->num_hooked_props++; in do_inherit_property()
1521 ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; in do_inherit_property()
1525 _zend_hash_append_ptr(&ce->properties_info, key, parent_info); in do_inherit_property()
1530 static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ in do_implement_interface() argument
1532 …if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_… in do_implement_interface()
1533 …, "%s %s could not implement interface %s", zend_get_object_type_uc(ce), ZSTR_VAL(ce->name), ZSTR_… in do_implement_interface()
1536 ZEND_ASSERT(ce != iface); in do_implement_interface()
1540 static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface) /* {{{ … in zend_do_inherit_interfaces() argument
1546 ce_num = ce->num_interfaces; in zend_do_inherit_interfaces()
1548 if (ce->type == ZEND_INTERNAL_CLASS) { in zend_do_inherit_interfaces()
1549ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_nu… in zend_do_inherit_interfaces()
1551ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_n… in zend_do_inherit_interfaces()
1558 if (ce->interfaces[i] == entry) { in zend_do_inherit_interfaces()
1563 ce->interfaces[ce->num_interfaces++] = entry; in zend_do_inherit_interfaces()
1566 ce->ce_flags |= ZEND_ACC_RESOLVED_INTERFACES; in zend_do_inherit_interfaces()
1569 while (ce_num < ce->num_interfaces) { in zend_do_inherit_interfaces()
1570 do_implement_interface(ce, ce->interfaces[ce_num++]); in zend_do_inherit_interfaces()
1577 zend_string *type_str = zend_type_to_string_resolved(parent->type, parent->ce); in emit_incompatible_class_constant_error()
1580 ZSTR_VAL(child->ce->name), in emit_incompatible_class_constant_error()
1582 ZSTR_VAL(parent->ce->name), in emit_incompatible_class_constant_error()
1595 return zend_perform_covariant_type_check(child->ce, child->type, parent->ce, parent->type); in class_constant_types_compatible()
1599 zend_class_entry *ce, zend_class_constant *parent_constant, zend_string *name);
1601 …lass_constant(zend_string *name, zend_class_constant *parent_const, zend_class_entry *ce) /* {{{ */ in do_inherit_class_constant() argument
1603 zval *zv = zend_hash_find_known_hash(&ce->constants_table, name); in do_inherit_class_constant()
1608 bool inherit = do_inherit_constant_check(ce, parent_const, name); in do_inherit_class_constant()
1612 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in do_inherit_class_constant()
1613 ce->ce_flags |= ZEND_ACC_HAS_AST_CONSTANTS; in do_inherit_class_constant()
1614 if (ce->parent->ce_flags & ZEND_ACC_IMMUTABLE) { in do_inherit_class_constant()
1621 if (ce->type & ZEND_INTERNAL_CLASS) { in do_inherit_class_constant()
1626 _zend_hash_append_ptr(&ce->constants_table, name, parent_const); in do_inherit_class_constant()
1631 void zend_build_properties_info_table(zend_class_entry *ce) in zend_build_properties_info_table() argument
1635 if (ce->default_properties_count == 0) { in zend_build_properties_info_table()
1639 ZEND_ASSERT(ce->properties_info_table == NULL); in zend_build_properties_info_table()
1640 size = sizeof(zend_property_info *) * ce->default_properties_count; in zend_build_properties_info_table()
1641 if (ce->type == ZEND_USER_CLASS) { in zend_build_properties_info_table()
1642 ce->properties_info_table = table = zend_arena_alloc(&CG(arena), size); in zend_build_properties_info_table()
1644 ce->properties_info_table = table = pemalloc(size, 1); in zend_build_properties_info_table()
1650 if (ce->parent && ce->parent->default_properties_count != 0) { in zend_build_properties_info_table()
1651 zend_property_info **parent_table = ce->parent->properties_info_table; in zend_build_properties_info_table()
1654 sizeof(zend_property_info *) * ce->parent->default_properties_count in zend_build_properties_info_table()
1658 if (ce->default_properties_count == ce->parent->default_properties_count) { in zend_build_properties_info_table()
1663 ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) { in zend_build_properties_info_table()
1664 if (prop->ce == ce && (prop->flags & ZEND_ACC_STATIC) == 0 in zend_build_properties_info_table()
1671 ZEND_API void zend_verify_hooked_property(zend_class_entry *ce, zend_property_info *prop_info, zend… in zend_verify_hooked_property() argument
1681 …"Cannot specify default value for virtual hooked property %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(p… in zend_verify_hooked_property()
1687 && Z_TYPE(ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]) == IS_UNDEF) { in zend_verify_hooked_property()
1688 ZVAL_NULL(&ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]); in zend_verify_hooked_property()
1698 ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); in zend_verify_hooked_property()
1707 …"Abstract property %s::$%s must specify at least one abstract hook", ZSTR_VAL(ce->name), ZSTR_VAL(… in zend_verify_hooked_property()
1716 prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); in zend_verify_hooked_property()
1729 zend_hooked_property_variance_error_ex(value_param_name, prop_info->ce->name, prop_info->name); in zend_hooked_property_variance_error()
1745 zend_class_entry *ce = prop_info->ce; in zend_verify_property_hook_variance() local
1746 return zend_perform_covariant_type_check(ce, prop_info->type, ce, value_arg_info->type); in zend_verify_property_hook_variance()
1749 ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, bool checke… in zend_do_inheritance_ex() argument
1755 if (UNEXPECTED(ce->ce_flags & ZEND_ACC_INTERFACE)) { in zend_do_inheritance_ex()
1758 …zend_error_noreturn(E_COMPILE_ERROR, "Interface %s cannot extend class %s", ZSTR_VAL(ce->name), ZS… in zend_do_inheritance_ex()
1764 …zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend enum %s", ZSTR_VAL(ce->name), ZSTR_VA… in zend_do_inheritance_ex()
1768 …zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend final class %s", ZSTR_VAL(ce->name), … in zend_do_inheritance_ex()
1774 …ZSTR_VAL(ce->name), parent_ce->ce_flags & ZEND_ACC_INTERFACE ? "interface" : "trait", ZSTR_VAL(par… in zend_do_inheritance_ex()
1779 …if (UNEXPECTED((ce->ce_flags & ZEND_ACC_READONLY_CLASS) != (parent_ce->ce_flags & ZEND_ACC_READONL… in zend_do_inheritance_ex()
1781 ce->ce_flags & ZEND_ACC_READONLY_CLASS ? "Readonly" : "Non-readonly", ZSTR_VAL(ce->name), in zend_do_inheritance_ex()
1786 if (ce->parent_name) { in zend_do_inheritance_ex()
1787 zend_string_release_ex(ce->parent_name, 0); in zend_do_inheritance_ex()
1789 ce->parent = parent_ce; in zend_do_inheritance_ex()
1790 ce->default_object_handlers = parent_ce->default_object_handlers; in zend_do_inheritance_ex()
1791 ce->ce_flags |= ZEND_ACC_RESOLVED_PARENT; in zend_do_inheritance_ex()
1797 if (ce->default_properties_count) { in zend_do_inheritance_ex()
1798 …zval *table = pemalloc(sizeof(zval) * (ce->default_properties_count + parent_ce->default_propertie… in zend_do_inheritance_ex()
1799 src = ce->default_properties_table + ce->default_properties_count; in zend_do_inheritance_ex()
1801 dst = end + ce->default_properties_count; in zend_do_inheritance_ex()
1802 ce->default_properties_table = table; in zend_do_inheritance_ex()
1808 pefree(src, ce->type == ZEND_INTERNAL_CLASS); in zend_do_inheritance_ex()
1809 end = ce->default_properties_table; in zend_do_inheritance_ex()
1811 …end = pemalloc(sizeof(zval) * parent_ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS… in zend_do_inheritance_ex()
1813 ce->default_properties_table = end; in zend_do_inheritance_ex()
1816 if (UNEXPECTED(parent_ce->type != ce->type)) { in zend_do_inheritance_ex()
1826 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in zend_do_inheritance_ex()
1827 ce->ce_flags |= ZEND_ACC_HAS_AST_PROPERTIES; in zend_do_inheritance_ex()
1837 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in zend_do_inheritance_ex()
1838 ce->ce_flags |= ZEND_ACC_HAS_AST_PROPERTIES; in zend_do_inheritance_ex()
1843 ce->default_properties_count += parent_ce->default_properties_count; in zend_do_inheritance_ex()
1849 if (ce->default_static_members_count) { in zend_do_inheritance_ex()
1850 …al *table = pemalloc(sizeof(zval) * (ce->default_static_members_count + parent_ce->default_static_… in zend_do_inheritance_ex()
1851 src = ce->default_static_members_table + ce->default_static_members_count; in zend_do_inheritance_ex()
1853 dst = end + ce->default_static_members_count; in zend_do_inheritance_ex()
1854 ce->default_static_members_table = table; in zend_do_inheritance_ex()
1860 pefree(src, ce->type == ZEND_INTERNAL_CLASS); in zend_do_inheritance_ex()
1861 end = ce->default_static_members_table; in zend_do_inheritance_ex()
1863 …end = pemalloc(sizeof(zval) * parent_ce->default_static_members_count, ce->type == ZEND_INTERNAL_C… in zend_do_inheritance_ex()
1865 ce->default_static_members_table = end; in zend_do_inheritance_ex()
1877 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in zend_do_inheritance_ex()
1878 ce->ce_flags |= ZEND_ACC_HAS_AST_STATICS; in zend_do_inheritance_ex()
1881 ce->default_static_members_count += parent_ce->default_static_members_count; in zend_do_inheritance_ex()
1882 if (!ZEND_MAP_PTR(ce->static_members_table)) { in zend_do_inheritance_ex()
1883 if (ce->type == ZEND_INTERNAL_CLASS && in zend_do_inheritance_ex()
1884 ce->info.internal.module->type == MODULE_PERSISTENT) { in zend_do_inheritance_ex()
1885 ZEND_MAP_PTR_NEW(ce->static_members_table); in zend_do_inheritance_ex()
1890 ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, property_info) { in zend_do_inheritance_ex()
1891 if (property_info->ce == ce) { in zend_do_inheritance_ex()
1901 zend_hash_extend(&ce->properties_info, in zend_do_inheritance_ex()
1902 zend_hash_num_elements(&ce->properties_info) + in zend_do_inheritance_ex()
1906 do_inherit_property(property_info, key, ce); in zend_do_inheritance_ex()
1910 if (ce->num_hooked_props) { in zend_do_inheritance_ex()
1911 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&ce->properties_info, key, property_info) { in zend_do_inheritance_ex()
1912 if (property_info->ce == ce && property_info->hooks) { in zend_do_inheritance_ex()
1913 zend_verify_hooked_property(ce, property_info, key); in zend_do_inheritance_ex()
1921 zend_hash_extend(&ce->constants_table, in zend_do_inheritance_ex()
1922 zend_hash_num_elements(&ce->constants_table) + in zend_do_inheritance_ex()
1926 do_inherit_class_constant(key, c, ce); in zend_do_inheritance_ex()
1931 zend_hash_extend(&ce->function_table, in zend_do_inheritance_ex()
1932 zend_hash_num_elements(&ce->function_table) + in zend_do_inheritance_ex()
1944 do_inherit_method(key, func, ce, 0, flags); in zend_do_inheritance_ex()
1948 do_inherit_parent_constructor(ce); in zend_do_inheritance_ex()
1950 if (ce->type == ZEND_INTERNAL_CLASS) { in zend_do_inheritance_ex()
1952 zend_do_inherit_interfaces(ce, parent_ce); in zend_do_inheritance_ex()
1955 if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) { in zend_do_inheritance_ex()
1956 ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; in zend_do_inheritance_ex()
1959ce->ce_flags |= parent_ce->ce_flags & (ZEND_HAS_STATIC_IN_METHODS | ZEND_ACC_HAS_TYPE_HINTS | ZEND… in zend_do_inheritance_ex()
1963 …ool check_trait_property_or_constant_value_compatibility(zend_class_entry *ce, zval *op1, zval *op… in check_trait_property_or_constant_value_compatibility() argument
1971 if (UNEXPECTED(zval_update_constant_ex(&op1_tmp, ce) != SUCCESS)) { in check_trait_property_or_constant_value_compatibility()
1979 if (UNEXPECTED(zval_update_constant_ex(&op2_tmp, ce) != SUCCESS)) { in check_trait_property_or_constant_value_compatibility()
2001 zend_class_entry *ce, zend_class_constant *parent_constant, zend_string *name in do_inherit_constant_check() argument
2003 zval *zv = zend_hash_find_known_hash(&ce->constants_table, name); in do_inherit_constant_check()
2009 …if (parent_constant->ce != child_constant->ce && (ZEND_CLASS_CONST_FLAGS(parent_constant) & ZEND_A… in do_inherit_constant_check()
2011 ZSTR_VAL(child_constant->ce->name), ZSTR_VAL(name), in do_inherit_constant_check()
2012 ZSTR_VAL(parent_constant->ce->name), ZSTR_VAL(name) in do_inherit_constant_check()
2016 if (child_constant->ce != parent_constant->ce && child_constant->ce != ce) { in do_inherit_constant_check()
2019 zend_get_object_type_uc(ce), in do_inherit_constant_check()
2020 ZSTR_VAL(ce->name), in do_inherit_constant_check()
2021 ZSTR_VAL(child_constant->ce->name), ZSTR_VAL(name), in do_inherit_constant_check()
2022 ZSTR_VAL(parent_constant->ce->name), ZSTR_VAL(name)); in do_inherit_constant_check()
2027 ZSTR_VAL(ce->name), ZSTR_VAL(name), in do_inherit_constant_check()
2029 zend_get_object_type(parent_constant->ce), in do_inherit_constant_check()
2030 ZSTR_VAL(parent_constant->ce->name), in do_inherit_constant_check()
2040 add_class_constant_compatibility_obligation(ce, child_constant, parent_constant, name); in do_inherit_constant_check()
2048 …face_constant(zend_string *name, zend_class_constant *c, zend_class_entry *ce, zend_class_entry *i… in do_inherit_iface_constant() argument
2050 if (do_inherit_constant_check(ce, c, name)) { in do_inherit_iface_constant()
2053 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in do_inherit_iface_constant()
2054 ce->ce_flags |= ZEND_ACC_HAS_AST_CONSTANTS; in do_inherit_iface_constant()
2062 if (ce->type & ZEND_INTERNAL_CLASS) { in do_inherit_iface_constant()
2067 zend_hash_update_ptr(&ce->constants_table, name, c); in do_inherit_iface_constant()
2072 static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ in do_interface_implementation() argument
2079 if (!(ce->ce_flags & ZEND_ACC_INTERFACE)) { in do_interface_implementation()
2093 do_inherit_iface_constant(key, c, ce, iface); in do_interface_implementation()
2097 do_inherit_method(key, func, ce, 1, flags); in do_interface_implementation()
2100 zend_hash_extend(&ce->properties_info, in do_interface_implementation()
2101 zend_hash_num_elements(&ce->properties_info) + in do_interface_implementation()
2106 do_inherit_property(prop, key, ce); in do_interface_implementation()
2109 do_implement_interface(ce, iface); in do_interface_implementation()
2111 zend_do_inherit_interfaces(ce, iface); in do_interface_implementation()
2116 ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ in zend_do_implement_interface() argument
2119 uint32_t current_iface_num = ce->num_interfaces; in zend_do_implement_interface()
2120 uint32_t parent_iface_num = ce->parent ? ce->parent->num_interfaces : 0; in zend_do_implement_interface()
2124 ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED); in zend_do_implement_interface()
2126 for (i = 0; i < ce->num_interfaces; i++) { in zend_do_implement_interface()
2127 if (ce->interfaces[i] == NULL) { in zend_do_implement_interface()
2128 …memmove(ce->interfaces + i, ce->interfaces + i + 1, sizeof(zend_class_entry*) * (--ce->num_interfa… in zend_do_implement_interface()
2130 } else if (ce->interfaces[i] == iface) { in zend_do_implement_interface()
2134 … "Class %s cannot implement previously implemented interface %s", ZSTR_VAL(ce->name), ZSTR_VAL(ifa… in zend_do_implement_interface()
2141 do_inherit_constant_check(ce, c, key); in zend_do_implement_interface()
2144 if (ce->num_interfaces >= current_iface_num) { in zend_do_implement_interface()
2145 if (ce->type == ZEND_INTERNAL_CLASS) { in zend_do_implement_interface()
2146ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (++cur… in zend_do_implement_interface()
2148ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (++cu… in zend_do_implement_interface()
2151 ce->interfaces[ce->num_interfaces++] = iface; in zend_do_implement_interface()
2153 do_interface_implementation(ce, iface); in zend_do_implement_interface()
2158 static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry **interfaces) /* {{… in zend_do_implement_interfaces() argument
2161 uint32_t num_parent_interfaces = ce->parent ? ce->parent->num_interfaces : 0; in zend_do_implement_interfaces()
2167 for (i = 0; i < ce->num_interfaces; i++) { in zend_do_implement_interfaces()
2170 add_dependency_obligation(ce, iface); in zend_do_implement_interfaces()
2174 …zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ZSTR_VAL(ce->name)… in zend_do_implement_interfaces()
2182 zend_get_object_type_uc(ce), in zend_do_implement_interfaces()
2183 ZSTR_VAL(ce->name), in zend_do_implement_interfaces()
2189 do_inherit_constant_check(ce, c, key); in zend_do_implement_interfaces()
2202 if (!(ce->ce_flags & ZEND_ACC_CACHED)) { in zend_do_implement_interfaces()
2203 for (i = 0; i < ce->num_interfaces; i++) { in zend_do_implement_interfaces()
2204 zend_string_release_ex(ce->interface_names[i].name, 0); in zend_do_implement_interfaces()
2205 zend_string_release_ex(ce->interface_names[i].lc_name, 0); in zend_do_implement_interfaces()
2207 efree(ce->interface_names); in zend_do_implement_interfaces()
2210 ce->num_interfaces = num_interfaces; in zend_do_implement_interfaces()
2211 ce->interfaces = interfaces; in zend_do_implement_interfaces()
2212 ce->ce_flags |= ZEND_ACC_RESOLVED_INTERFACES; in zend_do_implement_interfaces()
2215 do_implement_interface(ce, ce->interfaces[i]); in zend_do_implement_interfaces()
2220 do_interface_implementation(ce, ce->interfaces[i]); in zend_do_implement_interfaces()
2226 void zend_inheritance_check_override(zend_class_entry *ce) in zend_inheritance_check_override() argument
2230 if (ce->ce_flags & ZEND_ACC_TRAIT) { in zend_inheritance_check_override()
2234 ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, f) { in zend_inheritance_check_override()
2245 if (ce->num_hooked_props) { in zend_inheritance_check_override()
2247 ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) { in zend_inheritance_check_override()
2267 static zend_class_entry *fixup_trait_scope(const zend_function *fn, zend_class_entry *ce) in fixup_trait_scope() argument
2270 return fn->common.scope->ce_flags & ZEND_ACC_TRAIT ? ce : fn->common.scope; in fixup_trait_scope()
2273 static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_string *key, zend_f… in zend_add_trait_method() argument
2279 if ((existing_fn = zend_hash_find_ptr(&ce->function_table, key)) != NULL) { in zend_add_trait_method()
2296 existing_fn, fixup_trait_scope(existing_fn, ce), fn, fixup_trait_scope(fn, ce), in zend_add_trait_method()
2297 ce, NULL, ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_RESET_CHILD_OVERRIDE); in zend_add_trait_method()
2301 if (existing_fn->common.scope == ce) { in zend_add_trait_method()
2309 ZSTR_VAL(ce->name), ZSTR_VAL(name), in zend_add_trait_method()
2330 fn = zend_hash_update_ptr(&ce->function_table, key, new_fn); in zend_add_trait_method()
2331 zend_add_magic_method(ce, fn, key); in zend_add_trait_method()
2342 fn, fixup_trait_scope(fn, ce), existing_fn, fixup_trait_scope(existing_fn, ce), in zend_add_trait_method()
2343 ce, NULL, flags); in zend_add_trait_method()
2348 static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /* {{{ */ in zend_fixup_trait_method() argument
2352 fn->common.scope = ce; in zend_fixup_trait_method()
2355 ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; in zend_fixup_trait_method()
2358 ce->ce_flags |= ZEND_HAS_STATIC_IN_METHODS; in zend_fixup_trait_method()
2375 static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, zend_class_entry *ce in zend_traits_copy_functions() argument
2383 if (ce->trait_aliases) { in zend_traits_copy_functions()
2384 alias_ptr = ce->trait_aliases; in zend_traits_copy_functions()
2403 zend_add_trait_method(ce, alias->alias, lcname, &fn_copy); in zend_traits_copy_functions()
2417 if (ce->trait_aliases) { in zend_traits_copy_functions()
2418 alias_ptr = ce->trait_aliases; in zend_traits_copy_functions()
2441 zend_add_trait_method(ce, fn->common.function_name, fnname, &fn_copy); in zend_traits_copy_functions()
2446 static uint32_t zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait, zend_class_en… in zend_check_trait_usage() argument
2455 for (i = 0; i < ce->num_traits; i++) { in zend_check_trait_usage()
2460 …_COMPILE_ERROR, "Required Trait %s wasn't added to %s", ZSTR_VAL(trait->name), ZSTR_VAL(ce->name)); in zend_check_trait_usage()
2465 static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_entry **traits, Hash… in zend_traits_init_trait_structures() argument
2478 if (ce->trait_precedences) { in zend_traits_init_trait_structures()
2479 exclude_tables = ecalloc(ce->num_traits, sizeof(HashTable*)); in zend_traits_init_trait_structures()
2481 precedences = ce->trait_precedences; in zend_traits_init_trait_structures()
2482 ce->trait_precedences = NULL; in zend_traits_init_trait_structures()
2492 zend_check_trait_usage(ce, trait, traits); in zend_traits_init_trait_structures()
2521 trait_num = zend_check_trait_usage(ce, exclude_ce, traits); in zend_traits_init_trait_structures()
2544 ce->trait_precedences = precedences; in zend_traits_init_trait_structures()
2547 if (ce->trait_aliases) { in zend_traits_init_trait_structures()
2549 while (ce->trait_aliases[i]) { in zend_traits_init_trait_structures()
2554 while (ce->trait_aliases[i]) { in zend_traits_init_trait_structures()
2555 zend_trait_alias *cur_alias = ce->trait_aliases[i]; in zend_traits_init_trait_structures()
2556 cur_method_ref = &ce->trait_aliases[i]->trait_method; in zend_traits_init_trait_structures()
2566 zend_check_trait_usage(ce, trait, traits); in zend_traits_init_trait_structures()
2576 for (j = 0; j < ce->num_traits; j++) { in zend_traits_init_trait_structures()
2620 static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry **traits, HashTabl… in zend_do_traits_method_binding() argument
2627 for (i = 0; i < ce->num_traits; i++) { in zend_do_traits_method_binding()
2631 zend_traits_copy_functions(key, fn, ce, exclude_tables[i], aliases); in zend_do_traits_method_binding()
2642 for (i = 0; i < ce->num_traits; i++) { in zend_do_traits_method_binding()
2645 zend_traits_copy_functions(key, fn, ce, NULL, aliases); in zend_do_traits_method_binding()
2651 ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, fn) { in zend_do_traits_method_binding()
2652 zend_fixup_trait_method(fn, ce); in zend_do_traits_method_binding()
2657 static const zend_class_entry* find_first_constant_definition(const zend_class_entry *ce, zend_clas… in find_first_constant_definition() argument
2668 if (colliding_ce == ce) { in find_first_constant_definition()
2682 …const zend_class_entry *ce, const zend_class_constant *existing_constant, const zend_class_constan… in emit_incompatible_trait_constant_error() argument
2687 …ZSTR_VAL(find_first_constant_definition(ce, traits, current_trait, name, existing_constant->ce)->n… in emit_incompatible_trait_constant_error()
2688 ZSTR_VAL(trait_constant->ce->name), in emit_incompatible_trait_constant_error()
2690 ZSTR_VAL(ce->name) in emit_incompatible_trait_constant_error()
2695 …zend_class_entry *ce, zend_class_constant *trait_constant, zend_string *name, zend_class_entry **t… in do_trait_constant_check() argument
2699 zval *zv = zend_hash_find_known_hash(&ce->constants_table, name); in do_trait_constant_check()
2708 …emit_incompatible_trait_constant_error(ce, existing_constant, trait_constant, name, traits, curren… in do_trait_constant_check()
2713 …emit_incompatible_trait_constant_error(ce, existing_constant, trait_constant, name, traits, curren… in do_trait_constant_check()
2716 …inheritance_status status1 = zend_perform_covariant_type_check(ce, existing_constant->type, traits… in do_trait_constant_check()
2717 …_perform_covariant_type_check(traits[current_trait], trait_constant->type, ce, existing_constant->… in do_trait_constant_check()
2719 …emit_incompatible_trait_constant_error(ce, existing_constant, trait_constant, name, traits, curren… in do_trait_constant_check()
2724 …if (!check_trait_property_or_constant_value_compatibility(ce, &trait_constant->value, &existing_co… in do_trait_constant_check()
2726 …emit_incompatible_trait_constant_error(ce, existing_constant, trait_constant, name, traits, curren… in do_trait_constant_check()
2734 static void zend_do_traits_constant_binding(zend_class_entry *ce, zend_class_entry **traits) /* {{{… in zend_do_traits_constant_binding() argument
2738 for (i = 0; i < ce->num_traits; i++) { in zend_do_traits_constant_binding()
2747 if (do_trait_constant_check(ce, constant, constant_name, traits, i)) { in zend_do_traits_constant_binding()
2755 ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; in zend_do_traits_constant_binding()
2756 ce->ce_flags |= ZEND_ACC_HAS_AST_CONSTANTS; in zend_do_traits_constant_binding()
2763 constant->ce = ce; in zend_do_traits_constant_binding()
2771 zend_hash_update_ptr(&ce->constants_table, constant_name, constant); in zend_do_traits_constant_binding()
2778 static const zend_class_entry* find_first_property_definition(const zend_class_entry *ce, zend_clas… in find_first_property_definition() argument
2782 if (colliding_ce == ce) { in find_first_property_definition()
2795 static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_entry **traits) /* {{{… in zend_do_traits_property_binding() argument
2810 for (i = 0; i < ce->num_traits; i++) { in zend_do_traits_property_binding()
2818 if ((colliding_prop = zend_hash_find_ptr(&ce->properties_info, prop_name)) != NULL) { in zend_do_traits_property_binding()
2819 if ((colliding_prop->flags & ZEND_ACC_PRIVATE) && colliding_prop->ce != ce) { in zend_do_traits_property_binding()
2820 zend_hash_del(&ce->properties_info, prop_name); in zend_do_traits_property_binding()
2829 ZSTR_VAL(find_first_property_definition(ce, traits, i, prop_name, colliding_prop->ce)->name), in zend_do_traits_property_binding()
2830 ZSTR_VAL(property_info->ce->name), in zend_do_traits_property_binding()
2832 ZSTR_VAL(ce->name)); in zend_do_traits_property_binding()
2842 op1 = &ce->default_static_members_table[colliding_prop->offset]; in zend_do_traits_property_binding()
2847 op1 = &ce->default_properties_table[OBJ_PROP_TO_NUM(colliding_prop->offset)]; in zend_do_traits_property_binding()
2850 is_compatible = check_trait_property_or_constant_value_compatibility(ce, op1, op2); in zend_do_traits_property_binding()
2856 … ZSTR_VAL(find_first_property_definition(ce, traits, i, prop_name, colliding_prop->ce)->name), in zend_do_traits_property_binding()
2857 ZSTR_VAL(property_info->ce->name), in zend_do_traits_property_binding()
2859 ZSTR_VAL(ce->name)); in zend_do_traits_property_binding()
2867 if ((ce->ce_flags & ZEND_ACC_READONLY_CLASS) && !(property_info->flags & ZEND_ACC_READONLY)) { in zend_do_traits_property_binding()
2870 ZSTR_VAL(ce->name), in zend_do_traits_property_binding()
2871 ZSTR_VAL(property_info->ce->name), in zend_do_traits_property_binding()
2895 new_prop = zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, type); in zend_do_traits_property_binding()
2923 zend_fixup_trait_method(new_fn, ce); in zend_do_traits_property_binding()
2928 ce->ce_flags |= ZEND_ACC_USE_GUARDS; in zend_do_traits_property_binding()
2935 static void zend_do_bind_traits(zend_class_entry *ce, zend_class_entry **traits) /* {{{ */ in zend_do_bind_traits() argument
2940 ZEND_ASSERT(ce->num_traits > 0); in zend_do_bind_traits()
2943 zend_traits_init_trait_structures(ce, traits, &exclude_tables, &aliases); in zend_do_bind_traits()
2946 zend_do_traits_method_binding(ce, traits, exclude_tables, aliases); in zend_do_bind_traits()
2957 zend_do_traits_constant_binding(ce, traits); in zend_do_bind_traits()
2958 zend_do_traits_property_binding(ce, traits); in zend_do_bind_traits()
2984 void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */ in zend_verify_abstract_class() argument
2988 bool is_explicit_abstract = (ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) != 0; in zend_verify_abstract_class()
2989 bool can_be_abstract = (ce->ce_flags & (ZEND_ACC_ENUM|ZEND_ACC_ANON_CLASS)) == 0; in zend_verify_abstract_class()
2992 ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, func) { in zend_verify_abstract_class()
3004 ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { in zend_verify_abstract_class()
3020 zend_get_object_type_uc(ce), in zend_verify_abstract_class()
3021 ZSTR_VAL(ce->name), ai.cnt, in zend_verify_abstract_class()
3031 zend_get_object_type_uc(ce), in zend_verify_abstract_class()
3032 ZSTR_VAL(ce->name), ai.cnt, in zend_verify_abstract_class()
3041 ce->ce_flags &= ~ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; in zend_verify_abstract_class()
3090 static HashTable *get_or_init_obligations_for_class(zend_class_entry *ce) { in get_or_init_obligations_for_class() argument
3098 key = (zend_ulong) (uintptr_t) ce; in get_or_init_obligations_for_class()
3107 ce->ce_flags |= ZEND_ACC_UNRESOLVED_VARIANCE; in get_or_init_obligations_for_class()
3111 static void add_dependency_obligation(zend_class_entry *ce, zend_class_entry *dependency_ce) { in add_dependency_obligation() argument
3112 HashTable *obligations = get_or_init_obligations_for_class(ce); in add_dependency_obligation()
3120 zend_class_entry *ce, in add_compatibility_obligation() argument
3123 HashTable *obligations = get_or_init_obligations_for_class(ce); in add_compatibility_obligation()
3143 zend_class_entry *ce, const zend_property_info *child_prop, in add_property_compatibility_obligation() argument
3145 HashTable *obligations = get_or_init_obligations_for_class(ce); in add_property_compatibility_obligation()
3155 zend_class_entry *ce, const zend_class_constant *child_const, in add_class_constant_compatibility_obligation() argument
3157 HashTable *obligations = get_or_init_obligations_for_class(ce); in add_class_constant_compatibility_obligation()
3167 zend_class_entry *ce, const zend_property_info *hooked_prop, const zend_function *hook_func) { in add_property_hook_obligation() argument
3168 HashTable *obligations = get_or_init_obligations_for_class(ce); in add_property_hook_obligation()
3176 static void resolve_delayed_variance_obligations(zend_class_entry *ce);
3217 static void load_delayed_classes(zend_class_entry *ce) { in load_delayed_classes() argument
3240 ZSTR_VAL(ce->name), ZSTR_VAL(name)); in load_delayed_classes()
3245 static void resolve_delayed_variance_obligations(zend_class_entry *ce) { in resolve_delayed_variance_obligations() argument
3247 zend_ulong num_key = (zend_ulong) (uintptr_t) ce; in resolve_delayed_variance_obligations()
3258 zend_inheritance_check_override(ce); in resolve_delayed_variance_obligations()
3260 ce->ce_flags &= ~ZEND_ACC_UNRESOLVED_VARIANCE; in resolve_delayed_variance_obligations()
3261 ce->ce_flags |= ZEND_ACC_LINKED; in resolve_delayed_variance_obligations()
3265 static void check_unrecoverable_load_failure(const zend_class_entry *ce) { in check_unrecoverable_load_failure() argument
3271 && zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t)ce) == SUCCESS) { in check_unrecoverable_load_failure()
3273 "During inheritance of %s with variance dependencies", ZSTR_VAL(ce->name)); in check_unrecoverable_load_failure()
3278 if (ce->handler == (zend_function*)op_array) { \
3279 ce->handler = (zend_function*)new_op_array; \
3284 zend_op_array *op_array, zend_class_entry *ce, const zend_class_entry *pce) { in zend_lazy_method_load() argument
3291 new_op_array->scope = ce; in zend_lazy_method_load()
3300 zend_class_entry *ce; in zend_lazy_class_load() local
3303 ce = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry)); in zend_lazy_class_load()
3304 memcpy(ce, pce, sizeof(zend_class_entry)); in zend_lazy_class_load()
3305 ce->ce_flags &= ~ZEND_ACC_IMMUTABLE; in zend_lazy_class_load()
3306 ce->refcount = 1; in zend_lazy_class_load()
3307 ce->inheritance_cache = NULL; in zend_lazy_class_load()
3309 ZEND_MAP_PTR_NEW(ce->mutable_data); in zend_lazy_class_load()
3311 ZEND_MAP_PTR_INIT(ce->mutable_data, NULL); in zend_lazy_class_load()
3315 if (ce->default_properties_table) { in zend_lazy_class_load()
3316 zval *dst = emalloc(sizeof(zval) * ce->default_properties_count); in zend_lazy_class_load()
3317 zval *src = ce->default_properties_table; in zend_lazy_class_load()
3318 zval *end = src + ce->default_properties_count; in zend_lazy_class_load()
3320 ce->default_properties_table = dst; in zend_lazy_class_load()
3327 ce->function_table.pDestructor = ZEND_FUNCTION_DTOR; in zend_lazy_class_load()
3328 if (!(HT_FLAGS(&ce->function_table) & HASH_FLAG_UNINITIALIZED)) { in zend_lazy_class_load()
3329 p = emalloc(HT_SIZE(&ce->function_table)); in zend_lazy_class_load()
3330 memcpy(p, HT_GET_DATA_ADDR(&ce->function_table), HT_USED_SIZE(&ce->function_table)); in zend_lazy_class_load()
3331 HT_SET_DATA_ADDR(&ce->function_table, p); in zend_lazy_class_load()
3332 p = ce->function_table.arData; in zend_lazy_class_load()
3333 end = p + ce->function_table.nNumUsed; in zend_lazy_class_load()
3336 zend_op_array *new_op_array = Z_PTR(p->val) = zend_lazy_method_load(op_array, ce, pce); in zend_lazy_class_load()
3355 if (ce->default_static_members_table) { in zend_lazy_class_load()
3356 zval *dst = emalloc(sizeof(zval) * ce->default_static_members_count); in zend_lazy_class_load()
3357 zval *src = ce->default_static_members_table; in zend_lazy_class_load()
3358 zval *end = src + ce->default_static_members_count; in zend_lazy_class_load()
3360 ce->default_static_members_table = dst; in zend_lazy_class_load()
3365 ZEND_MAP_PTR_INIT(ce->static_members_table, NULL); in zend_lazy_class_load()
3368 if (!(HT_FLAGS(&ce->properties_info) & HASH_FLAG_UNINITIALIZED)) { in zend_lazy_class_load()
3369 p = emalloc(HT_SIZE(&ce->properties_info)); in zend_lazy_class_load()
3370 memcpy(p, HT_GET_DATA_ADDR(&ce->properties_info), HT_USED_SIZE(&ce->properties_info)); in zend_lazy_class_load()
3371 HT_SET_DATA_ADDR(&ce->properties_info, p); in zend_lazy_class_load()
3372 p = ce->properties_info.arData; in zend_lazy_class_load()
3373 end = p + ce->properties_info.nNumUsed; in zend_lazy_class_load()
3378 ZEND_ASSERT(prop_info->ce == pce); in zend_lazy_class_load()
3383 new_prop_info->ce = ce; in zend_lazy_class_load()
3392 … zend_op_array *hook = zend_lazy_method_load((zend_op_array *) new_prop_info->hooks[i], ce, pce); in zend_lazy_class_load()
3395 new_prop_info->ce = ce; in zend_lazy_class_load()
3404 if (!(HT_FLAGS(&ce->constants_table) & HASH_FLAG_UNINITIALIZED)) { in zend_lazy_class_load()
3405 p = emalloc(HT_SIZE(&ce->constants_table)); in zend_lazy_class_load()
3406 memcpy(p, HT_GET_DATA_ADDR(&ce->constants_table), HT_USED_SIZE(&ce->constants_table)); in zend_lazy_class_load()
3407 HT_SET_DATA_ADDR(&ce->constants_table, p); in zend_lazy_class_load()
3408 p = ce->constants_table.arData; in zend_lazy_class_load()
3409 end = p + ce->constants_table.nNumUsed; in zend_lazy_class_load()
3414 ZEND_ASSERT(c->ce == pce); in zend_lazy_class_load()
3418 new_c->ce = ce; in zend_lazy_class_load()
3422 return ce; in zend_lazy_class_load()
3426 # define UPDATE_IS_CACHEABLE(ce) do { \ argument
3427 if ((ce)->type == ZEND_USER_CLASS) { \
3428 is_cacheable &= (ce)->ce_flags; \
3433 # define UPDATE_IS_CACHEABLE(ce) do { \ argument
3434 is_cacheable &= (ce)->ce_flags; \
3438 ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name, ze… in zend_do_link_class() argument
3447 uint32_t is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; in zend_do_link_class()
3453 ZEND_ASSERT(!(ce->ce_flags & ZEND_ACC_LINKED)); in zend_do_link_class()
3455 if (ce->parent_name) { in zend_do_link_class()
3457 ce->parent_name, lc_parent_name, in zend_do_link_class()
3460 check_unrecoverable_load_failure(ce); in zend_do_link_class()
3466 if (ce->num_traits || ce->num_interfaces) { in zend_do_link_class()
3467 …traits_and_interfaces = do_alloca(sizeof(zend_class_entry*) * (ce->num_traits + ce->num_interfaces… in zend_do_link_class()
3469 for (i = 0; i < ce->num_traits; i++) { in zend_do_link_class()
3470 zend_class_entry *trait = zend_fetch_class_by_name(ce->trait_names[i].name, in zend_do_link_class()
3471 ce->trait_names[i].lc_name, ZEND_FETCH_CLASS_TRAIT); in zend_do_link_class()
3477 …zend_error_noreturn(E_ERROR, "%s cannot use %s - it is not a trait", ZSTR_VAL(ce->name), ZSTR_VAL(… in zend_do_link_class()
3495 if (ce->num_interfaces) { in zend_do_link_class()
3496 for (i = 0; i < ce->num_interfaces; i++) { in zend_do_link_class()
3498 ce->interface_names[i].name, ce->interface_names[i].lc_name, in zend_do_link_class()
3502 check_unrecoverable_load_failure(ce); in zend_do_link_class()
3506 traits_and_interfaces[ce->num_traits + i] = iface; in zend_do_link_class()
3514 if (ce->ce_flags & ZEND_ACC_ENUM) { in zend_do_link_class()
3522 if (ce->ce_flags & ZEND_ACC_IMMUTABLE && is_cacheable) { in zend_do_link_class()
3524 zend_class_entry *ret = zend_inheritance_cache_get(ce, parent, traits_and_interfaces); in zend_do_link_class()
3540 proto = ce; in zend_do_link_class()
3544 if (ce->ce_flags & ZEND_ACC_IMMUTABLE) { in zend_do_link_class()
3546 ce = zend_lazy_class_load(ce); in zend_do_link_class()
3548 Z_CE_P(zv) = ce; in zend_do_link_class()
3549 } else if (ce->ce_flags & ZEND_ACC_FILE_CACHED) { in zend_do_link_class()
3551 ce = zend_lazy_class_load(ce); in zend_do_link_class()
3552 ce->ce_flags &= ~ZEND_ACC_FILE_CACHED; in zend_do_link_class()
3554 Z_CE_P(zv) = ce; in zend_do_link_class()
3558 zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t) ce); in zend_do_link_class()
3562 CG(current_linking_class) = is_cacheable ? ce : NULL; in zend_do_link_class()
3564 if (ce->ce_flags & ZEND_ACC_ENUM) { in zend_do_link_class()
3567 zend_enum_register_funcs(ce); in zend_do_link_class()
3572 add_dependency_obligation(ce, parent); in zend_do_link_class()
3574 zend_do_inheritance(ce, parent); in zend_do_link_class()
3576 if (ce->num_traits) { in zend_do_link_class()
3577 zend_do_bind_traits(ce, traits_and_interfaces); in zend_do_link_class()
3579 if (ce->num_interfaces) { in zend_do_link_class()
3583 sizeof(zend_class_entry *) * (ce->num_interfaces + num_parent_interfaces)); in zend_do_link_class()
3589 memcpy(interfaces + num_parent_interfaces, traits_and_interfaces + ce->num_traits, in zend_do_link_class()
3590 sizeof(zend_class_entry *) * ce->num_interfaces); in zend_do_link_class()
3592 zend_do_implement_interfaces(ce, interfaces); in zend_do_link_class()
3594 zend_do_inherit_interfaces(ce, parent); in zend_do_link_class()
3596 if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT)) in zend_do_link_class()
3597 && (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) in zend_do_link_class()
3599 zend_verify_abstract_class(ce); in zend_do_link_class()
3601 if (ce->ce_flags & ZEND_ACC_ENUM) { in zend_do_link_class()
3602 zend_verify_enum(ce); in zend_do_link_class()
3604 if (ce->num_hooked_prop_variance_checks) { in zend_do_link_class()
3606 ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop_info) { in zend_do_link_class()
3607 if (prop_info->ce == ce && prop_info->hooks && prop_info->hooks[ZEND_PROPERTY_HOOK_SET]) { in zend_do_link_class()
3615 add_property_hook_obligation(ce, prop_info, prop_info->hooks[ZEND_PROPERTY_HOOK_SET]); in zend_do_link_class()
3626 if (ce->__tostring && !(ce->ce_flags & ZEND_ACC_TRAIT) in zend_do_link_class()
3627 && !zend_class_implements_interface(ce, zend_ce_stringable)) { in zend_do_link_class()
3628 ZEND_ASSERT(ce->__tostring->common.fn_flags & ZEND_ACC_TRAIT_CLONE); in zend_do_link_class()
3629 ce->ce_flags |= ZEND_ACC_RESOLVED_INTERFACES; in zend_do_link_class()
3630 ce->num_interfaces++; in zend_do_link_class()
3631 ce->interfaces = perealloc(ce->interfaces, in zend_do_link_class()
3632 sizeof(zend_class_entry *) * ce->num_interfaces, ce->type == ZEND_INTERNAL_CLASS); in zend_do_link_class()
3633 ce->interfaces[ce->num_interfaces - 1] = zend_ce_stringable; in zend_do_link_class()
3634 do_interface_implementation(ce, zend_ce_stringable); in zend_do_link_class()
3637 zend_build_properties_info_table(ce); in zend_do_link_class()
3649 if (!(ce->ce_flags & ZEND_ACC_UNRESOLVED_VARIANCE)) { in zend_do_link_class()
3650 zend_inheritance_check_override(ce); in zend_do_link_class()
3651 ce->ce_flags |= ZEND_ACC_LINKED; in zend_do_link_class()
3653 ce->ce_flags |= ZEND_ACC_NEARLY_LINKED; in zend_do_link_class()
3655 ce->ce_flags |= ZEND_ACC_CACHEABLE; in zend_do_link_class()
3657 load_delayed_classes(ce); in zend_do_link_class()
3658 if (ce->ce_flags & ZEND_ACC_UNRESOLVED_VARIANCE) { in zend_do_link_class()
3659 resolve_delayed_variance_obligations(ce); in zend_do_link_class()
3661 if (ce->ce_flags & ZEND_ACC_CACHEABLE) { in zend_do_link_class()
3662 ce->ce_flags &= ~ZEND_ACC_CACHEABLE; in zend_do_link_class()
3674 HashTable *ht = (HashTable*)ce->inheritance_cache; in zend_do_link_class()
3677 ce->inheritance_cache = NULL; in zend_do_link_class()
3678 new_ce = zend_inheritance_cache_add(ce, proto, parent, traits_and_interfaces, ht); in zend_do_link_class()
3681 ce = new_ce; in zend_do_link_class()
3682 Z_CE_P(zv) = ce; in zend_do_link_class()
3697 if (ZSTR_HAS_CE_CACHE(ce->name)) { in zend_do_link_class()
3698 ZSTR_SET_CE_CACHE(ce->name, ce); in zend_do_link_class()
3701 return ce; in zend_do_link_class()
3706 static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_entry *parent_ce) /*… in zend_can_early_bind() argument
3715 zval *zv = zend_hash_find_known_hash(&ce->function_table, key); in zend_can_early_bind()
3722 ce, NULL, in zend_can_early_bind()
3738 zv = zend_hash_find_known_hash(&ce->properties_info, key); in zend_can_early_bind()
3756 zv = zend_hash_find_known_hash(&ce->constants_table, key); in zend_can_early_bind()
3773 …l register_early_bound_ce(zval *delayed_early_binding, zend_string *lcname, zend_class_entry *ce) { in register_early_bound_ce() argument
3775 if (EXPECTED(!(ce->ce_flags & ZEND_ACC_PRELOADED))) { in register_early_bound_ce()
3777 Z_CE_P(delayed_early_binding) = ce; in register_early_bound_ce()
3782 if (zend_hash_add_ptr(EG(class_table), lcname, ce) != NULL) { in register_early_bound_ce()
3791 if (zend_hash_add_ptr(CG(class_table), lcname, ce) != NULL) { in register_early_bound_ce()
3797 ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_entry *parent_ce, z… in zend_try_early_bind() argument
3803 if (ce->ce_flags & ZEND_ACC_LINKED) { in zend_try_early_bind()
3804 ZEND_ASSERT(ce->parent == NULL); in zend_try_early_bind()
3805 if (UNEXPECTED(!register_early_bound_ce(delayed_early_binding, lcname, ce))) { in zend_try_early_bind()
3808 zend_observer_class_linked_notify(ce, lcname); in zend_try_early_bind()
3809 return ce; in zend_try_early_bind()
3812 uint32_t is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; in zend_try_early_bind()
3816 zend_class_entry *ret = zend_inheritance_cache_get(ce, parent_ce, NULL); in zend_try_early_bind()
3827 proto = ce; in zend_try_early_bind()
3832 status = zend_can_early_bind(ce, parent_ce); in zend_try_early_bind()
3835 if (ce->ce_flags & ZEND_ACC_IMMUTABLE) { in zend_try_early_bind()
3837 ce = zend_lazy_class_load(ce); in zend_try_early_bind()
3838 } else if (ce->ce_flags & ZEND_ACC_FILE_CACHED) { in zend_try_early_bind()
3840 ce = zend_lazy_class_load(ce); in zend_try_early_bind()
3841 ce->ce_flags &= ~ZEND_ACC_FILE_CACHED; in zend_try_early_bind()
3844 if (UNEXPECTED(!register_early_bound_ce(delayed_early_binding, lcname, ce))) { in zend_try_early_bind()
3849 CG(current_linking_class) = is_cacheable ? ce : NULL; in zend_try_early_bind()
3852 CG(zend_lineno) = ce->info.user.line_start; in zend_try_early_bind()
3858 zend_do_inheritance_ex(ce, parent_ce, status == INHERITANCE_SUCCESS); in zend_try_early_bind()
3860 zend_do_inherit_interfaces(ce, parent_ce); in zend_try_early_bind()
3862 zend_build_properties_info_table(ce); in zend_try_early_bind()
3863 …if ((ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_E… in zend_try_early_bind()
3864 zend_verify_abstract_class(ce); in zend_try_early_bind()
3866 zend_inheritance_check_override(ce); in zend_try_early_bind()
3867 ZEND_ASSERT(!(ce->ce_flags & ZEND_ACC_UNRESOLVED_VARIANCE)); in zend_try_early_bind()
3868 ce->ce_flags |= ZEND_ACC_LINKED; in zend_try_early_bind()
3880 HashTable *ht = (HashTable*)ce->inheritance_cache; in zend_try_early_bind()
3883 ce->inheritance_cache = NULL; in zend_try_early_bind()
3884 new_ce = zend_inheritance_cache_add(ce, proto, parent_ce, NULL, ht); in zend_try_early_bind()
3887 ce = new_ce; in zend_try_early_bind()
3888 Z_CE_P(zv) = ce; in zend_try_early_bind()
3896 if (ZSTR_HAS_CE_CACHE(ce->name)) { in zend_try_early_bind()
3897 ZSTR_SET_CE_CACHE(ce->name, ce); in zend_try_early_bind()
3899 zend_observer_class_linked_notify(ce, lcname); in zend_try_early_bind()
3901 return ce; in zend_try_early_bind()