|
@@ -79,8 +78,8 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
{
zval token;
int token_type;
- char *last_color = syntax_highlighter_ini->highlight_html;
- char *next_color;
+ const char *last_color = syntax_highlighter_ini->highlight_html;
+ const char *next_color;
zend_printf("", last_color);
/* highlight stuff coming back from zendlex() */
diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h
index 04688d65132b..2e399f408063 100644
--- a/Zend/zend_highlight.h
+++ b/Zend/zend_highlight.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -30,11 +29,11 @@
typedef struct _zend_syntax_highlighter_ini {
- char *highlight_html;
- char *highlight_comment;
- char *highlight_default;
- char *highlight_string;
- char *highlight_keyword;
+ const char *highlight_html;
+ const char *highlight_comment;
+ const char *highlight_default;
+ const char *highlight_string;
+ const char *highlight_keyword;
} zend_syntax_highlighter_ini;
diff --git a/Zend/zend_hrtime.c b/Zend/zend_hrtime.c
index 7fa36b1b654f..819f95c47662 100644
--- a/Zend/zend_hrtime.c
+++ b/Zend/zend_hrtime.c
@@ -1,14 +1,12 @@
/*
+----------------------------------------------------------------------+
- | Copyright (c) The PHP Group |
+ | Copyright © The PHP Group and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | https://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Niklas Keller |
| Author: Anatol Belski |
@@ -27,6 +25,8 @@
# include
# include
+ZEND_API clockid_t zend_hrtime_posix_clock_id = CLOCK_MONOTONIC;
+
#elif ZEND_HRTIME_PLATFORM_WINDOWS
# define WIN32_LEAN_AND_MEAN
@@ -66,5 +66,24 @@ void zend_startup_hrtime(void)
mach_timebase_info(&zend_hrtime_timerlib_info);
+#elif ZEND_HRTIME_PLATFORM_POSIX
+
+ struct timespec ts;
+
+#ifdef CLOCK_MONOTONIC_RAW
+ if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) {
+ zend_hrtime_posix_clock_id = CLOCK_MONOTONIC_RAW;
+ return;
+ }
+#endif
+
+ if (EXPECTED(0 == clock_gettime(zend_hrtime_posix_clock_id, &ts))) {
+ return;
+ }
+
+ // zend_error mechanism is not initialized at that point
+ fprintf(stderr, "No working CLOCK_MONOTONIC* found, this should never happen\n");
+ abort();
+
#endif
}
diff --git a/Zend/zend_hrtime.h b/Zend/zend_hrtime.h
index 994dd6da169e..6d802caacfe0 100644
--- a/Zend/zend_hrtime.h
+++ b/Zend/zend_hrtime.h
@@ -1,14 +1,12 @@
/*
+----------------------------------------------------------------------+
- | Copyright (c) The PHP Group |
+ | Copyright © The PHP Group and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | https://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Niklas Keller |
| Author: Anatol Belski |
@@ -44,7 +42,7 @@
#elif defined(_WIN32) || defined(_WIN64)
# undef ZEND_HRTIME_PLATFORM_WINDOWS
# define ZEND_HRTIME_PLATFORM_WINDOWS 1
-#elif HAVE_CLOCK_GETTIME_NSEC_NP
+#elif defined(HAVE_CLOCK_GETTIME_NSEC_NP)
# undef ZEND_HRTIME_PLATFORM_APPLE_GETTIME_NSEC
# define ZEND_HRTIME_PLATFORM_APPLE_GETTIME_NSEC 1
#elif defined(__APPLE__)
@@ -72,6 +70,10 @@ ZEND_API extern double zend_hrtime_timer_scale;
# include
ZEND_API extern mach_timebase_info_data_t zend_hrtime_timerlib_info;
+#elif ZEND_HRTIME_PLATFORM_POSIX
+
+ZEND_API extern clockid_t zend_hrtime_posix_clock_id;
+
#endif
#define ZEND_NANO_IN_SEC UINT64_C(1000000000)
@@ -92,10 +94,8 @@ static zend_always_inline zend_hrtime_t zend_hrtime(void)
return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom;
#elif ZEND_HRTIME_PLATFORM_POSIX
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
- if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC, &ts))) {
- return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec;
- }
- return 0;
+ clock_gettime(zend_hrtime_posix_clock_id, &ts);
+ return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec;
#elif ZEND_HRTIME_PLATFORM_HPUX
return (zend_hrtime_t) gethrtime();
#elif ZEND_HRTIME_PLATFORM_AIX
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index e657f4286797..8df6a5599d30 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -60,8 +59,8 @@ static void add_property_hook_obligation(
zend_class_entry *ce, const zend_property_info *hooked_prop, const zend_function *hook_func);
static void ZEND_COLD emit_incompatible_method_error(
- const zend_function *child, zend_class_entry *child_scope,
- const zend_function *parent, zend_class_entry *parent_scope,
+ const zend_function *child, const zend_class_entry *child_scope,
+ const zend_function *parent, const zend_class_entry *parent_scope,
inheritance_status status);
static void zend_type_copy_ctor(zend_type *const type, bool use_arena, bool persistent);
@@ -100,7 +99,7 @@ static zend_function *zend_duplicate_internal_function(const zend_function *func
{
zend_function *new_function;
- if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
+ if (UNEXPECTED(ce->type == ZEND_INTERNAL_CLASS)) {
new_function = (zend_function *)pemalloc(sizeof(zend_internal_function), 1);
memcpy(new_function, func, sizeof(zend_internal_function));
} else {
@@ -189,9 +188,9 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
if (ce->constructor) {
if (parent->constructor && UNEXPECTED(parent->constructor->common.fn_flags & ZEND_ACC_FINAL)) {
- zend_error_noreturn(E_ERROR, "Cannot override final %s::%s() with %s::%s()",
- ZSTR_VAL(parent->name), ZSTR_VAL(parent->constructor->common.function_name),
- ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
+ zend_error_noreturn(E_ERROR, "Cannot override final %s::__construct() with %s::__construct()",
+ ZSTR_VAL(parent->name),
+ ZSTR_VAL(ce->name));
}
return;
}
@@ -200,7 +199,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
}
/* }}} */
-char *zend_visibility_string(uint32_t fn_flags) /* {{{ */
+const char *zend_visibility_string(uint32_t fn_flags) /* {{{ */
{
if (fn_flags & ZEND_ACC_PUBLIC) {
return "public";
@@ -312,7 +311,7 @@ static zend_class_entry *lookup_class(zend_class_entry *scope, zend_string *name
/* Instanceof that's safe to use on unlinked classes. */
static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_entry *ce2) {
if (ce1 == ce2) {
- return 1;
+ return true;
}
if (ce1->ce_flags & ZEND_ACC_LINKED) {
@@ -320,7 +319,7 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en
}
if (ce1->parent) {
- zend_class_entry *parent_ce;
+ const zend_class_entry *parent_ce;
if (ce1->ce_flags & ZEND_ACC_RESOLVED_PARENT) {
parent_ce = ce1->parent;
} else {
@@ -331,7 +330,7 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en
/* It's not sufficient to only check the parent chain itself, as need to do a full
* recursive instanceof in case the parent interfaces haven't been copied yet. */
if (parent_ce && unlinked_instanceof(parent_ce, ce2)) {
- return 1;
+ return true;
}
}
@@ -342,7 +341,7 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en
* check here, as the parent interfaces might not have been fully copied yet. */
for (i = 0; i < ce1->num_interfaces; i++) {
if (unlinked_instanceof(ce1->interfaces[i], ce2)) {
- return 1;
+ return true;
}
}
} else {
@@ -352,19 +351,19 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en
ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD);
/* Avoid recursing if class implements itself. */
if (ce && ce != ce1 && unlinked_instanceof(ce, ce2)) {
- return 1;
+ return true;
}
}
}
}
- return 0;
+ return false;
}
static bool zend_type_permits_self(
const zend_type type, const zend_class_entry *scope, zend_class_entry *self) {
if (ZEND_TYPE_FULL_MASK(type) & MAY_BE_OBJECT) {
- return 1;
+ return true;
}
/* Any types that may satisfy self must have already been loaded at this point
@@ -376,11 +375,11 @@ static bool zend_type_permits_self(
zend_string *name = resolve_class_name(scope, ZEND_TYPE_NAME(*single_type));
const zend_class_entry *ce = lookup_class(self, name);
if (ce && unlinked_instanceof(self, ce)) {
- return 1;
+ return true;
}
}
} ZEND_TYPE_FOREACH_END();
- return 0;
+ return false;
}
static void track_class_dependency(zend_class_entry *ce, zend_string *class_name)
@@ -475,7 +474,7 @@ static inheritance_status zend_is_class_subtype_of_type(
zend_class_entry *fe_scope, zend_string *fe_class_name,
zend_class_entry *proto_scope, const zend_type proto_type) {
zend_class_entry *fe_ce = NULL;
- bool have_unresolved = 0;
+ bool have_unresolved = false;
/* If the parent has 'object' as a return type, any class satisfies the co-variant check */
if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_OBJECT) {
@@ -484,7 +483,7 @@ static inheritance_status zend_is_class_subtype_of_type(
* are not classes (such as typedefs). */
if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name);
if (!fe_ce) {
- have_unresolved = 1;
+ have_unresolved = true;
} else {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
@@ -495,7 +494,7 @@ static inheritance_status zend_is_class_subtype_of_type(
if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_CALLABLE) {
if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name);
if (!fe_ce) {
- have_unresolved = 1;
+ have_unresolved = true;
} else if (fe_ce == zend_ce_closure) {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
@@ -506,7 +505,7 @@ static inheritance_status zend_is_class_subtype_of_type(
if ((ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_STATIC) && (fe_scope->ce_flags & ZEND_ACC_FINAL)) {
if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name);
if (!fe_ce) {
- have_unresolved = 1;
+ have_unresolved = true;
} else if (fe_ce == fe_scope) {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
@@ -530,14 +529,14 @@ static inheritance_status zend_is_class_subtype_of_type(
}
continue;
case INHERITANCE_UNRESOLVED:
- have_unresolved = 1;
+ have_unresolved = true;
continue;
case INHERITANCE_SUCCESS:
if (!is_intersection) {
return INHERITANCE_SUCCESS;
}
continue;
- EMPTY_SWITCH_DEFAULT_CASE();
+ default: ZEND_UNREACHABLE();
}
}
@@ -562,7 +561,7 @@ static inheritance_status zend_is_class_subtype_of_type(
}
if (!fe_ce || !proto_ce) {
- have_unresolved = 1;
+ have_unresolved = true;
continue;
}
if (unlinked_instanceof(fe_ce, proto_ce)) {
@@ -671,7 +670,7 @@ static inheritance_status zend_is_intersection_subtype_of_type(
return early_exit_status == INHERITANCE_ERROR ? INHERITANCE_SUCCESS : INHERITANCE_ERROR;
}
-ZEND_API inheritance_status zend_perform_covariant_type_check(
+static inheritance_status zend_perform_covariant_type_check(
zend_class_entry *fe_scope, const zend_type fe_type,
zend_class_entry *proto_scope, const zend_type proto_type)
{
@@ -763,8 +762,8 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
}
static inheritance_status zend_do_perform_arg_type_hint_check(
- zend_class_entry *fe_scope, zend_arg_info *fe_arg_info,
- zend_class_entry *proto_scope, zend_arg_info *proto_arg_info) /* {{{ */
+ zend_class_entry *fe_scope, const zend_arg_info *fe_arg_info,
+ zend_class_entry *proto_scope, const zend_arg_info *proto_arg_info) /* {{{ */
{
if (!ZEND_TYPE_IS_SET(fe_arg_info->type) || ZEND_TYPE_PURE_MASK(fe_arg_info->type) == MAY_BE_ANY) {
/* Child with no type or mixed type is always compatible */
@@ -897,7 +896,7 @@ static inheritance_status zend_do_perform_implementation_check(
/* }}} */
static ZEND_COLD void zend_append_type_hint(
- smart_str *str, zend_class_entry *scope, const zend_arg_info *arg_info, bool return_hint) /* {{{ */
+ smart_str *str, const zend_class_entry *scope, const zend_arg_info *arg_info, bool return_hint) /* {{{ */
{
if (ZEND_TYPE_IS_SET(arg_info->type)) {
zend_string *type_str = zend_type_to_string_resolved(arg_info->type, scope);
@@ -911,12 +910,12 @@ static ZEND_COLD void zend_append_type_hint(
/* }}} */
static ZEND_COLD zend_string *zend_get_function_declaration(
- const zend_function *fptr, zend_class_entry *scope) /* {{{ */
+ const zend_function *fptr, const zend_class_entry *scope) /* {{{ */
{
smart_str str = {0};
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
- smart_str_appends(&str, "& ");
+ smart_str_appendc(&str, '&');
}
if (fptr->common.scope) {
@@ -924,7 +923,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
/* cut off on NULL byte ... class@anonymous */
smart_str_appends(&str, ZSTR_VAL(fptr->common.scope->name));
} else {
- smart_str_appendl(&str, ZSTR_VAL(fptr->common.scope->name), ZSTR_LEN(fptr->common.scope->name));
+ smart_str_append(&str, fptr->common.scope->name);
}
smart_str_appends(&str, "::");
}
@@ -942,7 +941,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
num_args++;
}
for (uint32_t i = 0; i < num_args;) {
- zend_append_type_hint(&str, scope, arg_info, 0);
+ zend_append_type_hint(&str, scope, arg_info, false);
if (ZEND_ARG_SEND_MODE(arg_info)) {
smart_str_appendc(&str, '&');
@@ -953,18 +952,14 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
}
smart_str_appendc(&str, '$');
- if (fptr->type == ZEND_INTERNAL_FUNCTION) {
- smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
- } else {
- smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
- }
+ smart_str_append(&str, arg_info->name);
if (i >= required && !ZEND_ARG_IS_VARIADIC(arg_info)) {
smart_str_appends(&str, " = ");
if (fptr->type == ZEND_INTERNAL_FUNCTION) {
- if (((zend_internal_arg_info*)arg_info)->default_value) {
- smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->default_value);
+ if (arg_info->default_value) {
+ smart_str_append(&str, arg_info->default_value);
} else {
smart_str_appends(&str, "");
}
@@ -1041,7 +1036,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
if (fptr->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
smart_str_appends(&str, ": ");
- zend_append_type_hint(&str, scope, fptr->common.arg_info - 1, 1);
+ zend_append_type_hint(&str, scope, fptr->common.arg_info - 1, true);
}
smart_str_0(&str);
@@ -1058,8 +1053,8 @@ static zend_always_inline uint32_t func_lineno(const zend_function *fn) {
}
static void ZEND_COLD emit_incompatible_method_error(
- const zend_function *child, zend_class_entry *child_scope,
- const zend_function *parent, zend_class_entry *parent_scope,
+ const zend_function *child, const zend_class_entry *child_scope,
+ const zend_function *parent, const zend_class_entry *parent_scope,
inheritance_status status) {
zend_string *parent_prototype = zend_get_function_declaration(parent, parent_scope);
zend_string *child_prototype = zend_get_function_declaration(child, child_scope);
@@ -1600,11 +1595,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
ce_num = ce->num_interfaces;
- if (ce->type == ZEND_INTERNAL_CLASS) {
- ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_num + if_num));
- } else {
- ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_num + if_num));
- }
+ ce->interfaces = (zend_class_entry **) perealloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_num + if_num), ce->type == ZEND_INTERNAL_CLASS);
/* Inherit the interfaces, only if they're not already inherited by the class */
while (if_num--) {
@@ -1673,7 +1664,7 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa
Z_CONSTANT_FLAGS(c->value) |= CONST_OWNED;
}
}
- if (ce->type & ZEND_INTERNAL_CLASS) {
+ if (ce->type == ZEND_INTERNAL_CLASS) {
c = pemalloc(sizeof(zend_class_constant), 1);
memcpy(c, parent_const, sizeof(zend_class_constant));
parent_const = c;
@@ -1785,7 +1776,7 @@ ZEND_API void zend_verify_hooked_property(const zend_class_entry *ce, zend_prope
&& (prop_info->flags & ZEND_ACC_PPP_SET_MASK)
&& (!prop_info->hooks[ZEND_PROPERTY_HOOK_GET] || !prop_info->hooks[ZEND_PROPERTY_HOOK_SET])) {
const char *prefix = !prop_info->hooks[ZEND_PROPERTY_HOOK_GET]
- ? "Write-only" : "Read-only";
+ ? "set-only" : "get-only";
zend_error_noreturn(E_COMPILE_ERROR,
"%s virtual property %s::$%s must not specify asymmetric visibility",
prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name));
@@ -2037,7 +2028,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par
}
zend_function *func;
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) {
- do_inherit_method(key, func, ce, 0, flags);
+ do_inherit_method(key, func, ce, false, flags);
} ZEND_HASH_FOREACH_END();
}
@@ -2155,7 +2146,7 @@ static void do_inherit_iface_constant(zend_string *name, zend_class_constant *c,
Z_CONSTANT_FLAGS(c->value) |= CONST_OWNED;
}
}
- if (ce->type & ZEND_INTERNAL_CLASS) {
+ if (ce->type == ZEND_INTERNAL_CLASS) {
ct = pemalloc(sizeof(zend_class_constant), 1);
memcpy(ct, c, sizeof(zend_class_constant));
c = ct;
@@ -2172,6 +2163,10 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
zend_class_constant *c;
uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY;
+ if (iface->num_interfaces) {
+ zend_do_inherit_interfaces(ce, iface);
+ }
+
if (!(ce->ce_flags & ZEND_ACC_INTERFACE)) {
/* We are not setting the prototype of overridden interface methods because of abstract
* constructors. See Zend/tests/interface_constructor_prototype_001.phpt. */
@@ -2190,7 +2185,7 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
} ZEND_HASH_FOREACH_END();
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->function_table, key, func) {
- do_inherit_method(key, func, ce, 1, flags);
+ do_inherit_method(key, func, ce, true, flags);
} ZEND_HASH_FOREACH_END();
zend_hash_extend(&ce->properties_info,
@@ -2203,9 +2198,6 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
} ZEND_HASH_FOREACH_END();
do_implement_interface(ce, iface);
- if (iface->num_interfaces) {
- zend_do_inherit_interfaces(ce, iface);
- }
}
/* }}} */
@@ -2238,11 +2230,7 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
} ZEND_HASH_FOREACH_END();
} else {
if (ce->num_interfaces >= current_iface_num) {
- if (ce->type == ZEND_INTERNAL_CLASS) {
- ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num));
- } else {
- ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num));
- }
+ ce->interfaces = (zend_class_entry **) perealloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num), ce->type == ZEND_INTERNAL_CLASS);
}
ce->interfaces[ce->num_interfaces++] = iface;
@@ -2267,7 +2255,6 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
if (UNEXPECTED(!(iface->ce_flags & ZEND_ACC_INTERFACE))) {
efree(interfaces);
zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ZSTR_VAL(ce->name), ZSTR_VAL(iface->name));
- return;
}
for (uint32_t j = 0; j < num_interfaces; j++) {
if (interfaces[j] == iface) {
@@ -2277,7 +2264,6 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
zend_get_object_type_uc(ce),
ZSTR_VAL(ce->name),
ZSTR_VAL(iface->name));
- return;
}
/* skip duplications */
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->constants_table, key, c) {
@@ -2528,7 +2514,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl
{
if (UNEXPECTED((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT)) {
zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", ZSTR_VAL(trait->name));
- return 0;
}
for (uint32_t i = 0; i < ce->num_traits; i++) {
@@ -2537,7 +2522,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl
}
}
zend_error_noreturn(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", ZSTR_VAL(trait->name), ZSTR_VAL(ce->name));
- return 0;
}
/* }}} */
@@ -3333,7 +3317,7 @@ static void check_unrecoverable_load_failure(const zend_class_entry *ce) {
* a dependence on the inheritance hierarchy of this specific class. Instead we fall back to
* a fatal error, as would happen if we did not allow exceptions in the first place. */
if (CG(unlinked_uses)
- && zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t)ce) == SUCCESS) {
+ && zend_hash_index_del(CG(unlinked_uses), (zend_ulong)(uintptr_t)ce) == SUCCESS) {
zend_exception_uncaught_error(
"During inheritance of %s with variance dependencies", ZSTR_VAL(ce->name));
}
@@ -3628,7 +3612,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
}
if (CG(unlinked_uses)) {
- zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t) ce);
+ zend_hash_index_del(CG(unlinked_uses), (zend_ulong)(uintptr_t) ce);
}
orig_linking_class = CG(current_linking_class);
diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h
index 7171a9385f3b..fdcbd95764b3 100644
--- a/Zend/zend_inheritance.h
+++ b/Zend/zend_inheritance.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index 30a508cd2e3c..093683526d31 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Zeev Suraski |
+----------------------------------------------------------------------+
@@ -41,7 +40,7 @@ static inline bool zend_is_whitespace(char c) {
*/
static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
{
- zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
+ const zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
int module_number = *(int *)arg;
return ini_entry->module_number == module_number;
@@ -70,9 +69,9 @@ static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stag
}
ini_entry->value = ini_entry->orig_value;
ini_entry->modifiable = ini_entry->orig_modifiable;
- ini_entry->modified = 0;
+ ini_entry->modified = false;
ini_entry->orig_value = NULL;
- ini_entry->orig_modifiable = 0;
+ ini_entry->orig_modifiable = false;
}
return SUCCESS;
}
@@ -82,12 +81,12 @@ static void free_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);
- zend_string_release_ex(entry->name, 1);
+ zend_string_release_ex(entry->name, true);
if (entry->value) {
zend_string_release(entry->value);
}
if (entry->orig_value) {
- zend_string_release_ex(entry->orig_value, 1);
+ zend_string_release_ex(entry->orig_value, true);
}
free(entry);
}
@@ -103,7 +102,7 @@ ZEND_API void zend_ini_startup(void) /* {{{ */
EG(ini_directives) = registered_zend_ini_directives;
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
- zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1);
+ zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, true);
}
/* }}} */
@@ -146,18 +145,18 @@ ZEND_API void zend_ini_deactivate(void) /* {{{ */
static void copy_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *old_entry = (zend_ini_entry*)Z_PTR_P(zv);
- zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
+ zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), true);
Z_PTR_P(zv) = new_entry;
memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
if (old_entry->name) {
- new_entry->name = zend_string_dup(old_entry->name, 1);
+ new_entry->name = zend_string_dup(old_entry->name, true);
}
if (old_entry->value) {
- new_entry->value = zend_string_dup(old_entry->value, 1);
+ new_entry->value = zend_string_dup(old_entry->value, true);
}
if (old_entry->orig_value) {
- new_entry->orig_value = zend_string_dup(old_entry->orig_value, 1);
+ new_entry->orig_value = zend_string_dup(old_entry->orig_value, true);
}
}
/* }}} */
@@ -167,7 +166,7 @@ ZEND_API void zend_copy_ini_directives(void) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1);
+ zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, true);
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
}
/* }}} */
@@ -194,7 +193,7 @@ static int ini_key_compare(Bucket *f, Bucket *s) /* {{{ */
ZEND_API void zend_ini_sort_entries(void) /* {{{ */
{
- zend_hash_sort(EG(ini_directives), ini_key_compare, 0);
+ zend_hash_sort(EG(ini_directives), ini_key_compare, false);
}
/* }}} */
@@ -224,9 +223,9 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
#endif
while (ini_entry->name) {
- p = pemalloc(sizeof(zend_ini_entry), 1);
+ p = pemalloc(sizeof(zend_ini_entry), true);
p->def = ini_entry;
- p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
+ p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, true);
p->on_modify = ini_entry->on_modify;
p->mh_arg1 = ini_entry->mh_arg1;
p->mh_arg2 = ini_entry->mh_arg2;
@@ -236,13 +235,13 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
p->displayer = ini_entry->displayer;
p->modifiable = ini_entry->modifiable;
- p->orig_modifiable = 0;
- p->modified = 0;
+ p->orig_modifiable = false;
+ p->modified = false;
p->module_number = module_number;
if (zend_hash_add_ptr(directives, p->name, (void*)p) == NULL) {
if (p->name) {
- zend_string_release_ex(p->name, 1);
+ zend_string_release_ex(p->name, true);
}
pefree(p, true);
zend_unregister_ini_entries_ex(module_number, module_type);
@@ -260,7 +259,7 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
}
} else {
p->value = ini_entry->value ?
- zend_string_init_interned(ini_entry->value, ini_entry->value_length, 1) : NULL;
+ zend_string_init_interned(ini_entry->value, ini_entry->value_length, true) : NULL;
if (p->on_modify) {
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
@@ -332,7 +331,7 @@ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */
{
- return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
+ return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, false);
}
/* }}} */
@@ -342,13 +341,13 @@ ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *v
zend_string *new_value;
new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST));
- ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
+ ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, false);
zend_string_release(new_value);
return ret;
}
/* }}} */
-ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
+ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, bool force_change) /* {{{ */
{
zend_result ret;
zend_string *new_value;
@@ -386,12 +385,12 @@ ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new
if (!EG(modified_ini_directives)) {
ALLOC_HASHTABLE(EG(modified_ini_directives));
- zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
+ zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, false);
}
if (!modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_modifiable = modifiable;
- ini_entry->modified = 1;
+ ini_entry->modified = true;
zend_hash_add_ptr(EG(modified_ini_directives), ini_entry->name, ini_entry);
}
@@ -428,7 +427,7 @@ ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage) /* {{{
}
if (EG(modified_ini_directives)) {
- if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
+ if (zend_restore_ini_entry_cb(ini_entry, stage) == SUCCESS) {
zend_hash_del(EG(modified_ini_directives), name);
} else {
return FAILURE;
@@ -457,7 +456,7 @@ ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name
* Data retrieval
*/
-ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig) /* {{{ */
+ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;
@@ -474,7 +473,7 @@ ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig)
}
/* }}} */
-ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig) /* {{{ */
+ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;
@@ -491,7 +490,7 @@ ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig)
}
/* }}} */
-ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists) /* {{{ */
+ZEND_API const char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists) /* {{{ */
{
zend_string *str = zend_ini_str_ex(name, name_length, orig, exists);
@@ -499,7 +498,7 @@ ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig
}
/* }}} */
-ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig) /* {{{ */
+ZEND_API const char *zend_ini_string(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_string *str = zend_ini_str(name, name_length, orig);
@@ -515,7 +514,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) {
if (exists) {
- *exists = 1;
+ *exists = true;
}
if (orig && ini_entry->modified) {
@@ -525,7 +524,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool
}
} else {
if (exists) {
- *exists = 0;
+ *exists = false;
}
return NULL;
}
@@ -534,7 +533,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig) /* {{{ */
{
- bool exists = 1;
+ bool exists = true;
zend_string *return_value;
return_value = zend_ini_str_ex(name, name_length, orig, &exists);
@@ -560,13 +559,18 @@ ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
}
/* }}} */
-ZEND_API bool zend_ini_parse_bool(zend_string *str)
+ZEND_API bool zend_ini_parse_bool(const zend_string *str)
{
+ /* May happen if an unknown INI setting is queried via zend_ini_bool_literal(),
+ * as zend_ini_str() would return NULL */
+ if (UNEXPECTED(str == NULL)) {
+ return false;
+ }
if (zend_string_equals_literal_ci(str, "true")
|| zend_string_equals_literal_ci(str, "yes")
|| zend_string_equals_literal_ci(str, "on")
) {
- return 1;
+ return true;
} else {
return atoi(ZSTR_VAL(str)) != 0;
}
@@ -610,12 +614,12 @@ static const char *zend_ini_consume_quantity_prefix(const char *const digits, co
return digits_consumed;
}
-static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
+static zend_ulong zend_ini_parse_quantity_internal(const zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
{
char *digits_end = NULL;
- char *str = ZSTR_VAL(value);
- char *str_end = &str[ZSTR_LEN(value)];
- char *digits = str;
+ const char *str = ZSTR_VAL(value);
+ const char *str_end = &str[ZSTR_LEN(value)];
+ const char *digits = str;
bool overflow = false;
zend_ulong factor;
smart_str invalid = {0};
@@ -844,19 +848,19 @@ static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_
}
/* }}} */
-ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr) /* {{{ */
+ZEND_API zend_long zend_ini_parse_quantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return (zend_long) zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_SIGNED, errstr);
}
/* }}} */
-ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr) /* {{{ */
+ZEND_API zend_ulong zend_ini_parse_uquantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_UNSIGNED, errstr);
}
/* }}} */
-ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting) /* {{{ */
+ZEND_API zend_long zend_ini_parse_quantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_long retval = zend_ini_parse_quantity(value, &errstr);
@@ -870,7 +874,7 @@ ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string
}
/* }}} */
-ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting) /* {{{ */
+ZEND_API zend_ulong zend_ini_parse_uquantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_ulong retval = zend_ini_parse_uquantity(value, &errstr);
@@ -886,21 +890,14 @@ ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_strin
ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
{
- int value;
- zend_string *tmp_value;
+ bool value;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
+ value = zend_ini_parse_bool(ini_entry->orig_value);
} else if (ini_entry->value) {
- tmp_value = ini_entry->value;
- } else {
- tmp_value = NULL;
- }
-
- if (tmp_value) {
- value = zend_ini_parse_bool(tmp_value);
+ value = zend_ini_parse_bool(ini_entry->value);
} else {
- value = 0;
+ value = false;
}
if (value) {
@@ -913,7 +910,7 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
{
- char *value;
+ const char *value;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
@@ -940,7 +937,7 @@ ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
ZEND_INI_DISP(display_link_numbers) /* {{{ */
{
- char *value;
+ const char *value;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
@@ -963,7 +960,7 @@ ZEND_INI_DISP(display_link_numbers) /* {{{ */
/* Standard message handlers */
ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
{
- bool *p = (bool *) ZEND_INI_GET_ADDR();
+ bool *p = ZEND_INI_GET_ADDR();
*p = zend_ini_parse_bool(new_value);
return SUCCESS;
}
@@ -971,7 +968,7 @@ ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
{
- zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
+ zend_long *p = ZEND_INI_GET_ADDR();
*p = zend_ini_parse_quantity_warn(new_value, entry->name);
return SUCCESS;
}
@@ -984,7 +981,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
return FAILURE;
}
- zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
+ zend_long *p = ZEND_INI_GET_ADDR();
*p = tmp;
return SUCCESS;
@@ -993,7 +990,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
{
- double *p = (double *) ZEND_INI_GET_ADDR();
+ double *p = ZEND_INI_GET_ADDR();
*p = zend_strtod(ZSTR_VAL(new_value), NULL);
return SUCCESS;
}
@@ -1001,7 +998,7 @@ ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateString) /* {{{ */
{
- char **p = (char **) ZEND_INI_GET_ADDR();
+ char **p = ZEND_INI_GET_ADDR();
*p = new_value ? ZSTR_VAL(new_value) : NULL;
return SUCCESS;
}
@@ -1013,7 +1010,7 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
return FAILURE;
}
- char **p = (char **) ZEND_INI_GET_ADDR();
+ char **p = ZEND_INI_GET_ADDR();
*p = new_value ? ZSTR_VAL(new_value) : NULL;
return SUCCESS;
}
@@ -1021,7 +1018,7 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateStr) /* {{{ */
{
- zend_string **p = (zend_string **) ZEND_INI_GET_ADDR();
+ zend_string **p = ZEND_INI_GET_ADDR();
*p = new_value;
return SUCCESS;
}
@@ -1033,7 +1030,7 @@ ZEND_API ZEND_INI_MH(OnUpdateStrNotEmpty) /* {{{ */
return FAILURE;
}
- zend_string **p = (zend_string **) ZEND_INI_GET_ADDR();
+ zend_string **p = ZEND_INI_GET_ADDR();
*p = new_value;
return SUCCESS;
}
diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h
index 5a7377f1181d..dbe650675b66 100644
--- a/Zend/zend_ini.h
+++ b/Zend/zend_ini.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Zeev Suraski |
+----------------------------------------------------------------------+
@@ -58,7 +57,7 @@ struct _zend_ini_entry {
uint8_t modifiable;
uint8_t orig_modifiable;
- uint8_t modified;
+ bool modified;
const zend_ini_entry_def *def;
};
@@ -82,18 +81,24 @@ ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change);
ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage);
-ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change);
+ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, bool force_change);
ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module);
-ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig);
-ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig);
-ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig);
-ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists);
+ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig);
+ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig);
+ZEND_API const char *zend_ini_string(const char *name, size_t name_length, bool orig);
+ZEND_API const char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig);
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_get_value(zend_string *name);
-ZEND_API bool zend_ini_parse_bool(zend_string *str);
+ZEND_API bool zend_ini_parse_bool(const zend_string *str);
+
+#define zend_ini_bool_literal(name) zend_ini_parse_bool(zend_ini_str((name), sizeof("" name) - 1, false))
+#define zend_ini_long_literal(name) zend_ini_long((name), sizeof("" name) - 1, false)
+#define zend_ini_double_literal(name) zend_ini_double((name), sizeof("" name) - 1, false)
+#define zend_ini_str_literal(name) zend_ini_str((name), sizeof("" name) - 1, false)
+#define zend_ini_string_literal(name) zend_ini_string((name), sizeof("" name) - 1, false)
/**
* Parses an ini quantity
@@ -130,16 +135,16 @@ ZEND_API bool zend_ini_parse_bool(zend_string *str);
* In any of these cases an error string is stored in *errstr (caller must
* release it), otherwise *errstr is set to NULL.
*/
-ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr);
+ZEND_API zend_long zend_ini_parse_quantity(const zend_string *value, zend_string **errstr);
/**
* Unsigned variant of zend_ini_parse_quantity
*/
-ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr);
+ZEND_API zend_ulong zend_ini_parse_uquantity(const zend_string *value, zend_string **errstr);
-ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting);
+ZEND_API zend_long zend_ini_parse_quantity_warn(const zend_string *value, zend_string *setting);
-ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting);
+ZEND_API zend_ulong zend_ini_parse_uquantity_warn(const zend_string *value, zend_string *setting);
ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
@@ -177,30 +182,20 @@ END_EXTERN_C()
#ifdef ZTS
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
- ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
+ ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr##_id)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
- ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
+ ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
- ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
+ ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
#else
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
- ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
+ ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
- ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
+ ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
- ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
+ ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) offsetof(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
#endif
-#define INI_INT(name) zend_ini_long((name), strlen(name), 0)
-#define INI_FLT(name) zend_ini_double((name), strlen(name), 0)
-#define INI_STR(name) zend_ini_string_ex((name), strlen(name), 0, NULL)
-#define INI_BOOL(name) ((bool) INI_INT(name))
-
-#define INI_ORIG_INT(name) zend_ini_long((name), strlen(name), 1)
-#define INI_ORIG_FLT(name) zend_ini_double((name), strlen(name), 1)
-#define INI_ORIG_STR(name) zend_ini_string((name), strlen(name), 1)
-#define INI_ORIG_BOOL(name) ((bool) INI_ORIG_INT(name))
-
#define REGISTER_INI_ENTRIES() zend_register_ini_entries_ex(ini_entries, module_number, type)
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries_ex(module_number, type)
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
@@ -257,6 +252,6 @@ typedef struct _zend_ini_parser_param {
# define ZEND_INI_GET_BASE() ((char *) ts_resource(*((int *) mh_arg2)))
#endif
-#define ZEND_INI_GET_ADDR() (ZEND_INI_GET_BASE() + (size_t) mh_arg1)
+#define ZEND_INI_GET_ADDR() ((void*)(ZEND_INI_GET_BASE() + (size_t) mh_arg1))
#endif /* ZEND_INI_H */
diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y
index 5f788f152fb6..d35853ab5acd 100644
--- a/Zend/zend_ini_parser.y
+++ b/Zend/zend_ini_parser.y
@@ -4,15 +4,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Zeev Suraski |
| Jani Taskinen |
@@ -57,7 +56,7 @@ static int get_int_val(zval *op) {
zend_string_free(Z_STR_P(op));
return val;
}
- EMPTY_SWITCH_DEFAULT_CASE()
+ default: ZEND_UNREACHABLE();
}
}
@@ -205,7 +204,7 @@ static ZEND_COLD void ini_error(const char *msg)
error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */
error_buf = (char *) emalloc(error_buf_len);
- sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno());
+ sprintf(error_buf, "%s in %s on line %" PRIu32 "\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno());
} else {
error_buf = estrdup("Invalid configuration directive\n");
}
diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h
index 62546413c7cb..c013564a10f4 100644
--- a/Zend/zend_ini_scanner.h
+++ b/Zend/zend_ini_scanner.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -30,7 +29,7 @@ typedef struct _zend_file_handle zend_file_handle;
#define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */
BEGIN_EXTERN_C()
-ZEND_COLD int zend_ini_scanner_get_lineno(void);
+ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void);
ZEND_COLD const char *zend_ini_scanner_get_filename(void);
zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode);
zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode);
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index b4013e8334f6..7fd51654ac82 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Zeev Suraski |
| Jani Taskinen |
@@ -230,7 +229,7 @@ void shutdown_ini_scanner(void)
/* }}} */
/* {{{ zend_ini_scanner_get_lineno() */
-ZEND_COLD int zend_ini_scanner_get_lineno(void)
+ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void)
{
return SCNG(lineno);
}
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index ce9cc00fdfb9..49169dfca234 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger |
+----------------------------------------------------------------------+
@@ -496,7 +495,7 @@ static zend_object *zend_internal_iterator_create(zend_class_entry *ce) {
zend_internal_iterator *intern = emalloc(sizeof(zend_internal_iterator));
zend_object_std_init(&intern->std, ce);
intern->iter = NULL;
- intern->rewind_called = 0;
+ intern->rewind_called = false;
return &intern->std;
}
@@ -537,7 +536,7 @@ static zend_internal_iterator *zend_internal_iterator_fetch(zval *This) {
static zend_result zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) {
if (!intern->rewind_called) {
zend_object_iterator *iter = intern->iter;
- intern->rewind_called = 1;
+ intern->rewind_called = true;
if (iter->funcs->rewind) {
iter->funcs->rewind(iter);
if (UNEXPECTED(EG(exception))) {
@@ -630,7 +629,7 @@ ZEND_METHOD(InternalIterator, rewind) {
RETURN_THROWS();
}
- intern->rewind_called = 1;
+ intern->rewind_called = true;
if (!intern->iter->funcs->rewind) {
/* Allow calling rewind() if no iteration has happened yet,
* even if the iterator does not support rewinding. */
diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h
index 883e482f510c..3aeac4fc8146 100644
--- a/Zend/zend_interfaces.h
+++ b/Zend/zend_interfaces.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_interfaces_arginfo.h b/Zend/zend_interfaces_arginfo.h
index 8a90166b2d80..836313e4f41b 100644
--- a/Zend/zend_interfaces_arginfo.h
+++ b/Zend/zend_interfaces_arginfo.h
@@ -1,4 +1,4 @@
-/* This is a generated file, edit the .stub.php file instead.
+/* This is a generated file, edit zend_interfaces.stub.php instead.
* Stub hash: a9c915c11e5989d8c7cf2d704ada09ca765670c3 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, Traversable, 0)
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c
index 64dbb0541a80..c05434486f89 100644
--- a/Zend/zend_iterators.c
+++ b/Zend/zend_iterators.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Wez Furlong |
| Marcus Boerger |
diff --git a/Zend/zend_iterators.h b/Zend/zend_iterators.h
index 75549188ed6b..973903768405 100644
--- a/Zend/zend_iterators.h
+++ b/Zend/zend_iterators.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Wez Furlong |
| Marcus Boerger |
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 897abbbe9773..b4dda00404ea 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -3,15 +3,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -821,9 +820,9 @@ parameter:
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, NULL,
NULL, $6 ? zend_ast_create_zval_from_str($6) : NULL, $7); }
| optional_cpp_modifiers optional_type_without_static
- is_reference is_variadic T_VARIABLE backup_doc_comment '=' expr optional_property_hook_list
- { $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, $8,
- NULL, $6 ? zend_ast_create_zval_from_str($6) : NULL, $9); }
+ is_reference is_variadic T_VARIABLE '=' expr backup_doc_comment optional_property_hook_list
+ { $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, $7,
+ NULL, $8 ? zend_ast_create_zval_from_str($8) : NULL, $9); }
;
optional_type_without_static:
@@ -901,16 +900,15 @@ return_type:
;
argument_list:
- '(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
+ '(' ')' { $$ = zend_ast_create_arg_list(0, ZEND_AST_ARG_LIST); }
| '(' non_empty_argument_list possible_comma ')' { $$ = $2; }
- | '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); }
;
non_empty_argument_list:
argument
- { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); }
+ { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $1); }
| non_empty_argument_list ',' argument
- { $$ = zend_ast_list_add($1, $3); }
+ { $$ = zend_ast_arg_list_add($1, $3); }
;
/* `clone_argument_list` is necessary to resolve a parser ambiguity (shift-reduce conflict)
@@ -923,25 +921,31 @@ non_empty_argument_list:
* syntax.
*/
clone_argument_list:
- '(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
+ '(' ')' { $$ = zend_ast_create_arg_list(0, ZEND_AST_ARG_LIST); }
| '(' non_empty_clone_argument_list possible_comma ')' { $$ = $2; }
- | '(' expr ',' ')' { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $2); }
- | '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); }
+ | '(' expr ',' ')' { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $2); }
;
non_empty_clone_argument_list:
expr ',' argument
- { $$ = zend_ast_create_list(2, ZEND_AST_ARG_LIST, $1, $3); }
+ { $$ = zend_ast_create_arg_list(2, ZEND_AST_ARG_LIST, $1, $3); }
| argument_no_expr
- { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); }
+ { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $1); }
| non_empty_clone_argument_list ',' argument
- { $$ = zend_ast_list_add($1, $3); }
+ { $$ = zend_ast_arg_list_add($1, $3); }
;
argument_no_expr:
identifier ':' expr
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3); }
- | T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
+ | T_ELLIPSIS
+ { $$ = zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, ZEND_PLACEHOLDER_VARIADIC); }
+ | '?'
+ { $$ = zend_ast_create(ZEND_AST_PLACEHOLDER_ARG); }
+ | identifier ':' '?'
+ { $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, zend_ast_create(ZEND_AST_PLACEHOLDER_ARG)); }
+ | T_ELLIPSIS expr
+ { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
;
argument:
@@ -1054,13 +1058,13 @@ trait_alias:
trait_method_reference:
identifier
- { $$ = zend_ast_create(ZEND_AST_METHOD_REFERENCE, NULL, $1); }
+ { $$ = zend_ast_create(ZEND_AST_TRAIT_METHOD_REFERENCE, NULL, $1); }
| absolute_trait_method_reference { $$ = $1; }
;
absolute_trait_method_reference:
class_name T_PAAMAYIM_NEKUDOTAYIM identifier
- { $$ = zend_ast_create(ZEND_AST_METHOD_REFERENCE, $1, $3); }
+ { $$ = zend_ast_create(ZEND_AST_TRAIT_METHOD_REFERENCE, $1, $3); }
;
method_body:
diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h
index 612c84547927..e502d91411b5 100644
--- a/Zend/zend_language_scanner.h
+++ b/Zend/zend_language_scanner.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -20,6 +19,7 @@
#ifndef ZEND_SCANNER_H
#define ZEND_SCANNER_H
+/* The zend_php_scanner_event enum is declared in zend_globals and we don't want everything to include zend_language_scanner.h */
#include "zend_globals.h"
typedef struct _zend_lex_state {
@@ -71,7 +71,7 @@ typedef struct _zend_heredoc_label {
/* Track locations of unclosed {, [, (, etc. for better syntax error reporting */
typedef struct _zend_nest_location {
char text;
- int lineno;
+ uint32_t lineno;
} zend_nest_location;
BEGIN_EXTERN_C()
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 3ecb2f8d0ee4..07f2d44cb5c6 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger |
| Nuno Lopes |
@@ -30,6 +29,7 @@
#include "zend_language_scanner_defs.h"
#include
+#include
#include "zend.h"
#ifdef ZEND_WIN32
# include
@@ -590,7 +590,7 @@ ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle)
return SUCCESS;
}
-static zend_op_array *zend_compile(int type)
+static zend_op_array *zend_compile(zend_function_type type)
{
zend_op_array *op_array = NULL;
bool original_in_compilation = CG(in_compilation);
@@ -600,7 +600,7 @@ static zend_op_array *zend_compile(int type)
CG(ast_arena) = zend_arena_create(1024 * 32);
if (!zendparse()) {
- int last_lineno = CG(zend_lineno);
+ uint32_t last_lineno = CG(zend_lineno);
zend_file_context original_file_context;
zend_oparray_context original_oparray_context;
zend_op_array *original_active_op_array = CG(active_op_array);
@@ -1140,7 +1140,7 @@ skip_escape_conversion:
unsigned char *str;
// TODO: avoid realocation ???
s = Z_STRVAL_P(zendlval);
- SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
+ SCNG(output_filter)(&str, &sz, (unsigned char *)s, Z_STRLEN_P(zendlval));
zval_ptr_dtor(zendlval);
ZVAL_STRINGL(zendlval, (char *) str, sz);
efree(str);
@@ -1172,7 +1172,7 @@ static bool strip_multiline_string_indentation(
const char *str = Z_STRVAL_P(zendlval), *end = str + Z_STRLEN_P(zendlval);
char *copy = Z_STRVAL_P(zendlval);
- int newline_count = 0;
+ uint32_t newline_count = 0;
size_t newline_len;
const char *nl;
@@ -1253,7 +1253,7 @@ static void copy_heredoc_label_stack(void *void_heredoc_label)
}
/* Check that { }, [ ], ( ) are nested correctly */
-static void report_bad_nesting(char opening, int opening_lineno, char closing)
+static void report_bad_nesting(char opening, uint32_t opening_lineno, char closing)
{
char buf[256];
size_t used = 0;
@@ -1361,7 +1361,7 @@ int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem)
{
int token;
int offset;
-int start_line = CG(zend_lineno);
+uint32_t start_line = CG(zend_lineno);
ZVAL_UNDEF(zendlval);
restart:
@@ -2499,7 +2499,7 @@ inline_char_handler:
if (YYCURSOR < YYLIMIT) {
YYCURSOR++;
} else {
- zend_throw_exception_ex(zend_ce_parse_error, 0, "Unterminated comment starting line %d", CG(zend_lineno));
+ zend_throw_exception_ex(zend_ce_parse_error, 0, "Unterminated comment starting line %" PRIu32, CG(zend_lineno));
if (PARSER_MODE()) {
RETURN_TOKEN(T_ERROR);
}
@@ -2616,7 +2616,7 @@ skip_escape_conversion:
zend_string *new_str;
s = Z_STRVAL_P(zendlval);
// TODO: avoid reallocation ???
- SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
+ SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, Z_STRLEN_P(zendlval));
new_str = zend_string_init(str, sz, 0);
if (str != s) {
efree(str);
@@ -2764,7 +2764,8 @@ skip_escape_conversion:
zend_ptr_stack_reverse_apply(¤t_state.heredoc_label_stack, copy_heredoc_label_stack);
- zend_exception_save();
+ zend_object *prev_exception = EG(exception);
+ EG(exception) = NULL;
while (heredoc_nesting_level) {
zval zv;
int retval;
@@ -2793,7 +2794,7 @@ skip_escape_conversion:
heredoc_nesting_level = 0;
}
}
- zend_exception_restore();
+ EG(exception) = prev_exception;
if (
(first_token == T_VARIABLE
diff --git a/Zend/zend_lazy_objects.c b/Zend/zend_lazy_objects.c
index 7d3d7f584ba9..a8316768ef5f 100644
--- a/Zend/zend_lazy_objects.c
+++ b/Zend/zend_lazy_objects.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Arnaud Le Blanc |
+----------------------------------------------------------------------+
@@ -479,6 +478,24 @@ static zend_object *zend_lazy_object_init_proxy(zend_object *obj)
/* prevent reentrant initialization */
OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY);
+ zval *properties_table_snapshot = NULL;
+
+ /* Snapshot dynamic properties */
+ HashTable *properties_snapshot = obj->properties;
+ if (properties_snapshot) {
+ GC_TRY_ADDREF(properties_snapshot);
+ }
+
+ /* Snapshot declared properties */
+ if (obj->ce->default_properties_count) {
+ zval *properties_table = obj->properties_table;
+ properties_table_snapshot = emalloc(sizeof(*properties_table_snapshot) * obj->ce->default_properties_count);
+
+ for (int i = 0; i < obj->ce->default_properties_count; i++) {
+ ZVAL_COPY_PROP(&properties_table_snapshot[i], &properties_table[i]);
+ }
+ }
+
/* Call factory */
zval retval;
int argc = 1;
@@ -492,33 +509,29 @@ static zend_object *zend_lazy_object_init_proxy(zend_object *obj)
zend_call_known_fcc(initializer, &retval, argc, &zobj, named_params);
if (UNEXPECTED(EG(exception))) {
- OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY;
- goto exit;
+ goto fail;
}
if (UNEXPECTED(Z_TYPE(retval) != IS_OBJECT)) {
- OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY;
zend_type_error("Lazy proxy factory must return an instance of a class compatible with %s, %s returned",
ZSTR_VAL(obj->ce->name),
zend_zval_value_name(&retval));
zval_ptr_dtor(&retval);
- goto exit;
+ goto fail;
}
if (UNEXPECTED(Z_TYPE(retval) != IS_OBJECT || !zend_lazy_object_compatible(Z_OBJ(retval), obj))) {
- OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY;
zend_type_error("The real instance class %s is not compatible with the proxy class %s. The proxy must be a instance of the same class as the real instance, or a sub-class with no additional properties, and no overrides of the __destructor or __clone methods.",
zend_zval_value_name(&retval),
ZSTR_VAL(obj->ce->name));
zval_ptr_dtor(&retval);
- goto exit;
+ goto fail;
}
if (UNEXPECTED(Z_OBJ(retval) == obj || zend_object_is_lazy(Z_OBJ(retval)))) {
- OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY;
zend_throw_error(NULL, "Lazy proxy factory must return a non-lazy object");
zval_ptr_dtor(&retval);
- goto exit;
+ goto fail;
}
zend_fcc_dtor(&info->u.initializer.fcc);
@@ -542,6 +555,21 @@ static zend_object *zend_lazy_object_init_proxy(zend_object *obj)
}
}
+ if (properties_table_snapshot) {
+ for (int i = 0; i < obj->ce->default_properties_count; i++) {
+ zval *p = &properties_table_snapshot[i];
+ /* Use zval_ptr_dtor directly here (not zend_object_dtor_property),
+ * as any reference type_source will have already been deleted in
+ * case the prop is not bound to this value anymore. */
+ i_zval_ptr_dtor(p);
+ }
+ efree(properties_table_snapshot);
+ }
+
+ if (properties_snapshot) {
+ zend_release_properties(properties_snapshot);
+ }
+
instance = Z_OBJ(retval);
exit:
@@ -554,6 +582,11 @@ static zend_object *zend_lazy_object_init_proxy(zend_object *obj)
}
return instance;
+
+fail:
+ OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY;
+ zend_lazy_object_revert_init(obj, properties_table_snapshot, properties_snapshot);
+ goto exit;
}
/* Initialize a lazy object. */
diff --git a/Zend/zend_lazy_objects.h b/Zend/zend_lazy_objects.h
index fc0a908e7ad2..8e66ee3facd6 100644
--- a/Zend/zend_lazy_objects.h
+++ b/Zend/zend_lazy_objects.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Arnaud Le Blanc |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 10aa9174cfcc..4e96ce0ec7da 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
diff --git a/Zend/zend_list.h b/Zend/zend_list.h
index 55ccf78dca10..108bd3fc3e7f 100644
--- a/Zend/zend_list.h
+++ b/Zend/zend_list.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c
index 28a275e6fce7..95ce31764bfc 100644
--- a/Zend/zend_llist.c
+++ b/Zend/zend_llist.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
diff --git a/Zend/zend_llist.h b/Zend/zend_llist.h
index 848543eba0a6..a92b8a59648c 100644
--- a/Zend/zend_llist.h
+++ b/Zend/zend_llist.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
diff --git a/Zend/zend_long.h b/Zend/zend_long.h
index 3796f1c5abab..303bacd03d4c 100644
--- a/Zend/zend_long.h
+++ b/Zend/zend_long.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Anatol Belski |
+----------------------------------------------------------------------+
@@ -51,9 +50,6 @@ typedef int32_t zend_off_t;
#endif
-/* Conversion macros. */
-#define ZEND_LTOA_BUF_LEN 65
-
#ifdef ZEND_ENABLE_ZVAL_LONG64
# define ZEND_LONG_FMT "%" PRId64
# define ZEND_ULONG_FMT "%" PRIu64
@@ -61,7 +57,6 @@ typedef int32_t zend_off_t;
# define ZEND_LONG_FMT_SPEC PRId64
# define ZEND_ULONG_FMT_SPEC PRIu64
# ifdef ZEND_WIN32
-# define ZEND_LTOA(i, s, len) _i64toa_s((i), (s), (len), 10)
# define ZEND_ATOL(s) _atoi64((s))
# define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base))
@@ -69,11 +64,6 @@ typedef int32_t zend_off_t;
# define ZEND_STRTOUL_PTR _strtoui64
# define ZEND_ABS _abs64
# else
-# define ZEND_LTOA(i, s, len) \
- do { \
- int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
- (s)[st] = '\0'; \
- } while (0)
# define ZEND_ATOL(s) atoll((s))
# define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base))
@@ -90,14 +80,8 @@ typedef int32_t zend_off_t;
# define ZEND_LONG_FMT_SPEC PRId32
# define ZEND_ULONG_FMT_SPEC PRIu32
# ifdef ZEND_WIN32
-# define ZEND_LTOA(i, s, len) _ltoa_s((i), (s), (len), 10)
# define ZEND_ATOL(s) atol((s))
# else
-# define ZEND_LTOA(i, s, len) \
- do { \
- int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
- (s)[st] = '\0'; \
- } while (0)
# define ZEND_ATOL(s) atol((s))
# endif
# define ZEND_STRTOL_PTR strtol
diff --git a/Zend/zend_map_ptr.h b/Zend/zend_map_ptr.h
index 4dfa0e5043ef..af3b5178aa4a 100644
--- a/Zend/zend_map_ptr.h
+++ b/Zend/zend_map_ptr.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_max_execution_timer.c b/Zend/zend_max_execution_timer.c
index 005ce14868a0..5d0eb1219c0b 100644
--- a/Zend/zend_max_execution_timer.c
+++ b/Zend/zend_max_execution_timer.c
@@ -1,14 +1,12 @@
/*
+----------------------------------------------------------------------+
- | Copyright (c) The PHP Group |
+ | Copyright © The PHP Group and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | https://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Kévin Dunglas |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_max_execution_timer.h b/Zend/zend_max_execution_timer.h
index 6557d6c91845..3839ea4cf676 100644
--- a/Zend/zend_max_execution_timer.h
+++ b/Zend/zend_max_execution_timer.h
@@ -1,14 +1,12 @@
/*
+----------------------------------------------------------------------+
- | Copyright (c) The PHP Group |
+ | Copyright © The PHP Group and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | https://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Kévin Dunglas |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_mmap.h b/Zend/zend_mmap.h
index 201fd84d074d..d56196c24687 100644
--- a/Zend/zend_mmap.h
+++ b/Zend/zend_mmap.h
@@ -1,12 +1,15 @@
/*
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | Zend Engine |
+ +----------------------------------------------------------------------+
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+ +----------------------------------------------------------------------+
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Max Kellermann |
+----------------------------------------------------------------------+
diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h
index 2d8cf88e1d12..3a98b1c06e29 100644
--- a/Zend/zend_modules.h
+++ b/Zend/zend_modules.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -31,7 +30,7 @@
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module
-#define ZEND_MODULE_API_NO 20250925
+#define ZEND_MODULE_API_NO 20250926
#ifdef ZTS
#define USING_ZTS 1
#else
diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c
index 9459920b6332..28be8126b117 100644
--- a/Zend/zend_multibyte.c
+++ b/Zend/zend_multibyte.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Masaki Fujimoto |
| Rui Hirokawa |
@@ -35,7 +34,7 @@ static const char *dummy_encoding_name_getter(const zend_encoding *encoding)
static bool dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding)
{
- return 0;
+ return false;
}
static const zend_encoding *dummy_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size)
@@ -114,8 +113,8 @@ ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions
* populated, we need to reinitialize script_encoding here.
*/
{
- const char *value = zend_ini_string("zend.script_encoding", sizeof("zend.script_encoding") - 1, 0);
- zend_multibyte_set_script_encoding_by_string(value, strlen(value));
+ const zend_string *value = zend_ini_str_literal("zend.script_encoding");
+ zend_multibyte_set_script_encoding_by_string(ZSTR_VAL(value), ZSTR_LEN(value));
}
return SUCCESS;
}
@@ -195,7 +194,7 @@ ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *ne
return SUCCESS;
}
- if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, 1)) {
+ if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, true)) {
return FAILURE;
}
diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h
index 16ba56ec69fd..41480ed6f86b 100644
--- a/Zend/zend_multibyte.h
+++ b/Zend/zend_multibyte.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Masaki Fujimoto |
| Rui Hirokawa |
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index 200bedd88cac..6457f85f64fb 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Sascha Schumann |
| Ard Biesheuvel |
@@ -342,7 +341,6 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
- return 0;
}
return ret;
}
@@ -355,7 +353,6 @@ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, si
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
- return 0;
}
return ret;
}
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 1a2c70fac1e0..9e993627a74a 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -46,6 +45,9 @@
#define IN_ISSET ZEND_GUARD_PROPERTY_ISSET
#define IN_HOOK ZEND_GUARD_PROPERTY_HOOK
+static zend_arg_info zend_call_trampoline_arginfo[1] = {{0}};
+static zend_arg_info zend_property_hook_arginfo[1] = {{0}};
+
static zend_always_inline bool zend_objects_check_stack_limit(void)
{
#ifdef ZEND_CHECK_STACK_LIMIT
@@ -106,8 +108,7 @@ ZEND_API HashTable *rebuild_object_properties_internal(zend_object *zobj) /* {{{
/* Implements the fast path for array cast */
ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /* {{{ */
{
- zend_property_info *prop_info;
- zend_class_entry *ce = zobj->ce;
+ const zend_class_entry *ce = zobj->ce;
HashTable *ht;
zval* prop;
int i;
@@ -118,7 +119,7 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /*
if (ce->default_properties_count) {
zend_hash_real_init_mixed(ht);
for (i = 0; i < ce->default_properties_count; i++) {
- prop_info = ce->properties_info_table[i];
+ const zend_property_info *prop_info = ce->properties_info_table[i];
if (!prop_info) {
continue;
@@ -192,7 +193,7 @@ ZEND_API HashTable *zend_std_get_gc(zend_object *zobj, zval **table, int *n) /*
ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /* {{{ */
{
- zend_class_entry *ce = object->ce;
+ const zend_class_entry *ce = object->ce;
zval retval;
HashTable *ht;
@@ -334,7 +335,7 @@ static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property(
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
ZSTR_VAL(obj->ce->name), ZSTR_VAL(member));
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
- zend_class_entry *ce = obj->ce;
+ const zend_class_entry *ce = obj->ce;
zend_objects_store_del(obj);
if (!EG(exception)) {
/* We cannot continue execution and have to throw an exception */
@@ -347,7 +348,7 @@ static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property(
}
static ZEND_COLD zend_never_inline void zend_readonly_property_unset_error(
- zend_class_entry *ce, zend_string *member) {
+ const zend_class_entry *ce, const zend_string *member) {
zend_throw_error(NULL, "Cannot unset readonly property %s::$%s",
ZSTR_VAL(ce->name), ZSTR_VAL(member));
}
@@ -680,7 +681,7 @@ static ZEND_FUNCTION(zend_parent_hook_set_trampoline);
static bool zend_is_in_hook(const zend_property_info *prop_info)
{
- zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_execute_data *execute_data = EG(current_execute_data);
if (!execute_data || !EX(func) || !EX(func)->common.prop_info) {
return false;
}
@@ -711,7 +712,7 @@ static bool zend_should_call_hook(const zend_property_info *prop_info, const zen
return true;
}
-static ZEND_COLD void zend_throw_no_prop_backing_value_access(zend_string *class_name, zend_string *prop_name, bool is_read)
+static ZEND_COLD void zend_throw_no_prop_backing_value_access(const zend_string *class_name, const zend_string *prop_name, bool is_read)
{
zend_throw_error(NULL, "Must not %s virtual property %s::$%s",
is_read ? "read from" : "write to",
@@ -719,7 +720,7 @@ static ZEND_COLD void zend_throw_no_prop_backing_value_access(zend_string *class
}
static bool zend_call_get_hook(
- const zend_property_info *prop_info, zend_string *prop_name,
+ const zend_property_info *prop_info, const zend_string *prop_name,
zend_function *get, zend_object *zobj, zval *rv)
{
if (!zend_should_call_hook(prop_info, zobj)) {
@@ -814,7 +815,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
zend_function *get = prop_info->hooks[ZEND_PROPERTY_HOOK_GET];
if (!get) {
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
- zend_throw_error(NULL, "Property %s::$%s is write-only",
+ zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s",
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
return &EG(uninitialized_zval);
}
@@ -842,7 +843,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
goto exit;
}
- zend_class_entry *ce = zobj->ce;
+ const zend_class_entry *ce = zobj->ce;
if (!zend_call_get_hook(prop_info, name, get, zobj, rv)) {
if (EG(exception)) {
@@ -850,7 +851,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
}
/* Reads from backing store can only occur in hooks, and hence will always remain simple. */
- zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_execute_data *execute_data = EG(current_execute_data);
if (cache_slot && EX(opline) && EX(opline)->opcode == ZEND_FETCH_OBJ_R && EX(opline)->op1_type == IS_UNUSED) {
ZEND_SET_PROPERTY_HOOK_SIMPLE_READ(cache_slot);
}
@@ -1020,7 +1021,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
/* }}} */
static zend_always_inline bool property_uses_strict_types(void) {
- zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_execute_data *execute_data = EG(current_execute_data);
return execute_data
&& execute_data->func
&& ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data));
@@ -1179,7 +1180,7 @@ found:;
if (!set) {
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
- zend_throw_error(NULL, "Property %s::$%s is read-only", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
+ zend_throw_error(NULL, "Cannot write to get-only virtual property %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
variable_ptr = &EG(error_zval);
goto exit;
}
@@ -1312,7 +1313,7 @@ found:;
}
/* }}} */
-static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry *ce) /* {{{ */
+static ZEND_COLD zend_never_inline void zend_bad_array_access(const zend_class_entry *ce) /* {{{ */
{
zend_throw_error(NULL, "Cannot use object of type %s as array", ZSTR_VAL(ce->name));
}
@@ -1320,7 +1321,7 @@ static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry *
ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */
{
- zend_class_entry *ce = object->ce;
+ const zend_class_entry *ce = object->ce;
zval tmp_offset;
/* arrayaccess_funcs_ptr is set if (and only if) the class implements zend_ce_arrayaccess */
@@ -1371,7 +1372,7 @@ ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int ty
ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value) /* {{{ */
{
- zend_class_entry *ce = object->ce;
+ const zend_class_entry *ce = object->ce;
zval tmp_offset;
zend_class_arrayaccess_funcs *funcs = ce->arrayaccess_funcs_ptr;
@@ -1394,7 +1395,7 @@ ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *
// todo: make zend_std_has_dimension return bool as well
ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */
{
- zend_class_entry *ce = object->ce;
+ const zend_class_entry *ce = object->ce;
zval retval, tmp_offset;
bool result;
@@ -1427,6 +1428,8 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
uintptr_t property_offset;
const zend_property_info *prop_info = NULL;
+ ZEND_ASSERT(type != BP_VAR_R && type != BP_VAR_IS);
+
#if DEBUG_OBJECT_HANDLERS
fprintf(stderr, "Ptr object #%d property: %s\n", zobj->handle, ZSTR_VAL(name));
#endif
@@ -1460,7 +1463,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
return zend_std_get_property_ptr_ptr(instance, name, type, cache_slot);
}
- if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
+ if (UNEXPECTED(type == BP_VAR_RW)) {
if (prop_info) {
zend_typed_property_uninitialized_access(prop_info, name);
retval = &EG(error_zval);
@@ -1532,7 +1535,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
if (UNEXPECTED(!zobj->properties)) {
rebuild_object_properties_internal(zobj);
}
- if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
+ if (UNEXPECTED(type == BP_VAR_RW)) {
zend_error(E_WARNING, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
}
retval = zend_hash_add(zobj->properties, name, &EG(uninitialized_zval));
@@ -1697,7 +1700,7 @@ ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void
ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset) /* {{{ */
{
- zend_class_entry *ce = object->ce;
+ const zend_class_entry *ce = object->ce;
zval tmp_offset;
zend_class_arrayaccess_funcs *funcs = ce->arrayaccess_funcs_ptr;
@@ -1713,7 +1716,7 @@ ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset) /* {{{
}
/* }}} */
-static zend_never_inline zend_function *zend_get_parent_private_method(zend_class_entry *scope, zend_class_entry *ce, zend_string *function_name) /* {{{ */
+static zend_never_inline zend_function *zend_get_parent_private_method(const zend_class_entry *scope, const zend_class_entry *ce, zend_string *function_name) /* {{{ */
{
zval *func;
zend_function *fbc;
@@ -1761,18 +1764,15 @@ ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_
}
/* }}} */
-ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static) /* {{{ */
+ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(
+ const zend_function *fbc, zend_string *method_name) /* {{{ */
{
size_t mname_len;
zend_op_array *func;
- zend_function *fbc = is_static ? ce->__callstatic : ce->__call;
/* We use non-NULL value to avoid useless run_time_cache allocation.
* The low bit must be zero, to not be interpreted as a MAP_PTR offset.
*/
static const void *dummy = (void*)(intptr_t)2;
- static const zend_arg_info arg_info[1] = {{0}};
-
- ZEND_ASSERT(fbc);
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
func = &EG(trampoline).op_array;
@@ -1787,12 +1787,10 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE
| ZEND_ACC_PUBLIC
| ZEND_ACC_VARIADIC
- | (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD));
+ | (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD|ZEND_ACC_STATIC));
+ func->fn_flags2 = 0;
/* Attributes outlive the trampoline because they are created by the compiler. */
func->attributes = fbc->common.attributes;
- if (is_static) {
- func->fn_flags |= ZEND_ACC_STATIC;
- }
func->opcodes = &EG(call_trampoline_op);
ZEND_MAP_PTR_INIT(func->run_time_cache, (void**)dummy);
func->scope = fbc->common.scope;
@@ -1821,12 +1819,24 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
func->prop_info = NULL;
func->num_args = 0;
func->required_num_args = 0;
- func->arg_info = (zend_arg_info *) arg_info;
+ func->arg_info = zend_call_trampoline_arginfo;
return (zend_function*)func;
}
/* }}} */
+ZEND_API void zend_free_trampoline(zend_function *func)
+{
+ ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE);
+
+ if (func == &EG(trampoline)) {
+ EG(trampoline).common.attributes = NULL;
+ EG(trampoline).common.function_name = NULL;
+ } else {
+ efree(func);
+ }
+}
+
static ZEND_FUNCTION(zend_parent_hook_get_trampoline)
{
zend_object *obj = Z_PTR_P(ZEND_THIS);
@@ -1838,7 +1848,7 @@ static ZEND_FUNCTION(zend_parent_hook_get_trampoline)
}
zval rv;
- zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv);
+ const zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv);
if (retval == &rv) {
RETVAL_COPY_VALUE(retval);
} else {
@@ -1874,9 +1884,6 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
const zend_property_info *prop_info,
zend_property_hook_kind kind, zend_string *prop_name)
{
- static const zend_internal_arg_info arg_info[2] = {
- { .name = "value" }
- };
zend_function *func;
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
func = &EG(trampoline);
@@ -1891,6 +1898,7 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
func->common.arg_flags[1] = 0;
func->common.arg_flags[2] = 0;
func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE;
+ func->common.fn_flags2 = 0;
func->common.function_name = zend_string_concat3(
"$", 1, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name),
kind == ZEND_PROPERTY_HOOK_GET ? "::get" : "::set", 5);
@@ -1901,7 +1909,7 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
func->common.scope = prop_info->ce;
func->common.prototype = NULL;
func->common.prop_info = prop_info;
- func->common.arg_info = (zend_arg_info *) arg_info;
+ func->common.arg_info = zend_property_hook_arginfo;
func->internal_function.handler = kind == ZEND_PROPERTY_HOOK_GET
? ZEND_FN(zend_parent_hook_get_trampoline)
: ZEND_FN(zend_parent_hook_set_trampoline);
@@ -1913,12 +1921,6 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
return func;
}
-static zend_always_inline zend_function *zend_get_user_call_function(zend_class_entry *ce, zend_string *method_name) /* {{{ */
-{
- return zend_get_call_trampoline_func(ce, method_name, 0);
-}
-/* }}} */
-
ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(const zend_function *fbc, const zend_string *method_name, const zend_class_entry *scope) /* {{{ */
{
zend_throw_error(NULL, "Call to %s method %s::%s() from %s%s",
@@ -1942,7 +1944,6 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
zval *func;
zend_function *fbc;
zend_string *lc_method_name;
- zend_class_entry *scope;
ALLOCA_FLAG(use_heap);
if (EXPECTED(key != NULL)) {
@@ -1960,7 +1961,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
ZSTR_ALLOCA_FREE(lc_method_name, use_heap);
}
if (zobj->ce->__call) {
- return zend_get_user_call_function(zobj->ce, method_name);
+ return zend_get_call_trampoline_func(zobj->ce->__call, method_name);
} else {
return NULL;
}
@@ -1970,7 +1971,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
/* Check access level */
if (fbc->op_array.fn_flags & (ZEND_ACC_CHANGED|ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
- scope = zend_get_executed_scope();
+ const zend_class_entry *scope = zend_get_executed_scope();
if (fbc->common.scope != scope) {
if (fbc->op_array.fn_flags & ZEND_ACC_CHANGED) {
@@ -1986,7 +1987,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
if (UNEXPECTED(fbc->op_array.fn_flags & ZEND_ACC_PRIVATE)
|| UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fbc), scope))) {
if (zobj->ce->__call) {
- fbc = zend_get_user_call_function(zobj->ce, method_name);
+ fbc = zend_get_call_trampoline_func(zobj->ce->__call, method_name);
} else {
zend_bad_method_call(fbc, method_name, scope);
fbc = NULL;
@@ -2007,14 +2008,8 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
}
/* }}} */
-static zend_always_inline zend_function *zend_get_user_callstatic_function(zend_class_entry *ce, zend_string *method_name) /* {{{ */
-{
- return zend_get_call_trampoline_func(ce, method_name, 1);
-}
-/* }}} */
-
static zend_always_inline zend_function *get_static_method_fallback(
- zend_class_entry *ce, zend_string *function_name)
+ const zend_class_entry *ce, zend_string *function_name)
{
zend_object *object;
if (ce->__call &&
@@ -2024,15 +2019,15 @@ static zend_always_inline zend_function *get_static_method_fallback(
* see: tests/classes/__call_004.phpt */
ZEND_ASSERT(object->ce->__call);
- return zend_get_user_call_function(object->ce, function_name);
+ return zend_get_call_trampoline_func(object->ce->__call, function_name);
} else if (ce->__callstatic) {
- return zend_get_user_callstatic_function(ce, function_name);
+ return zend_get_call_trampoline_func(ce->__callstatic, function_name);
} else {
return NULL;
}
}
-ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key) /* {{{ */
+ZEND_API zend_function *zend_std_get_static_method(const zend_class_entry *ce, zend_string *function_name, const zval *key) /* {{{ */
{
zend_string *lc_function_name;
if (EXPECTED(key != NULL)) {
@@ -2046,7 +2041,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
if (EXPECTED(func)) {
fbc = Z_FUNC_P(func);
if (!(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
- zend_class_entry *scope = zend_get_executed_scope();
+ const zend_class_entry *scope = zend_get_executed_scope();
ZEND_ASSERT(!(fbc->common.fn_flags & ZEND_ACC_PUBLIC));
if (!zend_check_method_accessible(fbc, scope)) {
zend_function *fallback_fbc = get_static_method_fallback(ce, function_name);
@@ -2093,7 +2088,6 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
{
- int i;
zval *p;
if (class_type->default_static_members_count && !CE_STATIC_MEMBERS(class_type)) {
@@ -2102,7 +2096,7 @@ ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
}
ZEND_MAP_PTR_SET(class_type->static_members_table, emalloc(sizeof(zval) * class_type->default_static_members_count));
- for (i = 0; i < class_type->default_static_members_count; i++) {
+ for (uint32_t i = 0; i < class_type->default_static_members_count; i++) {
p = &class_type->default_static_members_table[i];
if (Z_TYPE_P(p) == IS_INDIRECT) {
zval *q = &CE_STATIC_MEMBERS(class_type->parent)[i];
@@ -2194,12 +2188,16 @@ ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *c
static ZEND_COLD zend_never_inline void zend_bad_constructor_call(const zend_function *constructor, const zend_class_entry *scope) /* {{{ */
{
if (scope) {
- zend_throw_error(NULL, "Call to %s %s::%s() from scope %s",
- zend_visibility_string(constructor->common.fn_flags), ZSTR_VAL(constructor->common.scope->name),
- ZSTR_VAL(constructor->common.function_name), ZSTR_VAL(scope->name)
+ zend_throw_error(NULL, "Call to %s %s::__construct() from scope %s",
+ zend_visibility_string(constructor->common.fn_flags),
+ ZSTR_VAL(constructor->common.scope->name),
+ ZSTR_VAL(scope->name)
);
} else {
- zend_throw_error(NULL, "Call to %s %s::%s() from global scope", zend_visibility_string(constructor->common.fn_flags), ZSTR_VAL(constructor->common.scope->name), ZSTR_VAL(constructor->common.function_name));
+ zend_throw_error(NULL, "Call to %s %s::__construct() from global scope",
+ zend_visibility_string(constructor->common.fn_flags),
+ ZSTR_VAL(constructor->common.scope->name)
+ );
}
}
/* }}} */
@@ -2437,7 +2435,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
if (!get) {
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
- zend_throw_error(NULL, "Property %s::$%s is write-only",
+ zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s",
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
return 0;
} else {
@@ -2526,7 +2524,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
if (!value || (Z_PROP_FLAG_P(value) & IS_PROP_LAZY)) {
zobj = zend_lazy_object_init(zobj);
if (!zobj) {
- result = 0;
+ result = false;
goto exit;
}
@@ -2544,7 +2542,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
}
}
- result = 0;
+ result = false;
goto exit;
}
/* }}} */
@@ -2559,7 +2557,7 @@ ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *w
{
switch (type) {
case IS_STRING: {
- zend_class_entry *ce = readobj->ce;
+ const zend_class_entry *ce = readobj->ce;
if (ce->__tostring) {
zval retval;
GC_ADDREF(readobj);
@@ -2592,7 +2590,7 @@ ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *w
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
{
zend_class_entry *ce = obj->ce;
- zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));
+ const zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));
if (func == NULL) {
return FAILURE;
@@ -2693,3 +2691,9 @@ ZEND_API const zend_object_handlers std_object_handlers = {
zend_std_compare_objects, /* compare */
NULL, /* get_properties_for */
};
+
+void zend_object_handlers_startup(void) {
+ zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGUMENTS);
+ zend_call_trampoline_arginfo[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0));
+ zend_property_hook_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_VALUE);
+}
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index 84d0b57d7aa2..8ed4803c3f0e 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -205,7 +204,7 @@ typedef zend_result (*zend_object_do_operation_t)(uint8_t opcode, zval *result,
struct _zend_object_handlers {
/* offset of real object header (usually zero) */
- int offset;
+ size_t offset;
/* object handlers */
zend_object_free_obj_t free_obj; /* required */
zend_object_dtor_obj_t dtor_obj; /* required */
@@ -237,18 +236,17 @@ struct _zend_object_handlers {
BEGIN_EXTERN_C()
extern const ZEND_API zend_object_handlers std_object_handlers;
-#define zend_get_std_object_handlers() \
- (&std_object_handlers)
-
-#define zend_get_function_root_class(fbc) \
- ((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)
+static zend_always_inline const zend_object_handlers *zend_get_std_object_handlers(void)
+{
+ return &std_object_handlers;
+}
#define ZEND_PROPERTY_ISSET 0x0 /* Property exists and is not NULL */
#define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
#define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */
ZEND_API void zend_class_init_statics(zend_class_entry *ce);
-ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
+ZEND_API zend_function *zend_std_get_static_method(const zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, struct _zend_property_info **prop_info);
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type);
ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *ce, const zend_string *property_name);
@@ -291,18 +289,20 @@ static zend_always_inline HashTable *zend_std_get_properties_ex(zend_object *obj
/* Implements the fast path for array cast */
ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj);
-#define ZEND_STD_BUILD_OBJECT_PROPERTIES_ARRAY_COMPATIBLE(object) ( \
- /* We can use zend_std_build_object_properties_array() for objects \
- * without properties ht and with standard handlers */ \
- Z_OBJ_P(object)->properties == NULL \
- && Z_OBJ_HT_P(object)->get_properties_for == NULL \
- && Z_OBJ_HT_P(object)->get_properties == zend_std_get_properties \
- /* For initialized proxies we need to forward to the real instance */ \
- && ( \
- !zend_object_is_lazy_proxy(Z_OBJ_P(object)) \
- || !zend_lazy_object_initialized(Z_OBJ_P(object)) \
- ) \
-)
+static zend_always_inline bool ZEND_STD_BUILD_OBJECT_PROPERTIES_ARRAY_COMPATIBLE(const zval *zv) {
+ /* We can use zend_std_build_object_properties_array() for objects
+ * without properties ht and with standard handlers */
+ const zend_object *obj = Z_OBJ_P(zv);
+
+ return obj->properties == NULL
+ && obj->handlers->get_properties_for == NULL
+ && obj->handlers->get_properties == zend_std_get_properties
+ /* For initialized proxies we need to forward to the real instance */
+ && (
+ !zend_object_is_lazy_proxy(obj)
+ || !zend_lazy_object_initialized(obj)
+ );
+}
/* Handler for objects that cannot be meaningfully compared.
* Only objects with the same identity will be considered equal. */
@@ -312,9 +312,8 @@ ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_
ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_string *prop_info_name, bool is_dynamic);
-ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static);
-
-ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member);
+ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(const zend_function *fbc, zend_string *method_name);
+ZEND_API void zend_free_trampoline(zend_function *func);
ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member);
@@ -336,20 +335,14 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_property_info *prop_info);
-#define zend_release_properties(ht) do { \
- if (ht) { \
- zend_array_release(ht); \
- } \
-} while (0)
-
-#define zend_free_trampoline(func) do { \
- if ((func) == &EG(trampoline)) { \
- EG(trampoline).common.attributes = NULL; \
- EG(trampoline).common.function_name = NULL; \
- } else { \
- efree(func); \
- } \
- } while (0)
+void zend_object_handlers_startup(void);
+
+static zend_always_inline void zend_release_properties(HashTable *ht)
+{
+ if (ht) {
+ zend_array_release(ht);
+ }
+}
/* Fallback to default comparison implementation if the arguments aren't both objects
* and have the same compare() handler. You'll likely want to use this unless you
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index 6f6a82638944..2fc264742cd1 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -194,14 +193,14 @@ ZEND_API zend_object* ZEND_FASTCALL zend_objects_new(zend_class_entry *ce)
return object;
}
-ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object)
+ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, const zend_object *old_object)
{
bool has_clone_method = old_object->ce->clone != NULL;
if (old_object->ce->default_properties_count) {
- zval *src = old_object->properties_table;
+ const zval *src = old_object->properties_table;
zval *dst = new_object->properties_table;
- zval *end = src + old_object->ce->default_properties_count;
+ const zval *end = src + old_object->ce->default_properties_count;
do {
i_zval_ptr_dtor(dst);
diff --git a/Zend/zend_objects.h b/Zend/zend_objects.h
index 712fd442da5a..0930fa043101 100644
--- a/Zend/zend_objects.h
+++ b/Zend/zend_objects.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -25,7 +24,7 @@
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce);
ZEND_API zend_object* ZEND_FASTCALL zend_objects_new(zend_class_entry *ce);
-ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object);
+ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, const zend_object *old_object);
ZEND_API void zend_object_std_dtor(zend_object *object);
ZEND_API void zend_objects_destroy_object(zend_object *object);
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index c19873cf3be3..537cad8a3644 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -44,8 +43,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_call_destructors(zend_objects_sto
{
EG(flags) |= EG_FLAGS_OBJECT_STORE_NO_REUSE;
if (objects->top > 1) {
- uint32_t i;
- for (i = 1; i < objects->top; i++) {
+ for (uint32_t i = 1; i < objects->top; i++) {
zend_object *obj = objects->object_buckets[i];
if (IS_OBJ_VALID(obj)) {
if (!(OBJ_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
@@ -128,20 +126,19 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
/* Store objects API */
static ZEND_COLD zend_never_inline void ZEND_FASTCALL zend_objects_store_put_cold(zend_object *object)
{
- int handle;
uint32_t new_size = 2 * EG(objects_store).size;
EG(objects_store).object_buckets = (zend_object **) erealloc(EG(objects_store).object_buckets, new_size * sizeof(zend_object*));
/* Assign size after realloc, in case it fails */
EG(objects_store).size = new_size;
- handle = EG(objects_store).top++;
+ uint32_t handle = EG(objects_store).top++;
object->handle = handle;
EG(objects_store).object_buckets[handle] = object;
}
ZEND_API void ZEND_FASTCALL zend_objects_store_put(zend_object *object)
{
- int handle;
+ uint32_t handle;
/* When in shutdown sequence - do not reuse previously freed handles, to make sure
* the dtors for newly created objects are called in zend_objects_store_call_destructors() loop
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index 86c3a49f8c8c..434ac4499e7f 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans |
| Zeev Suraski |
@@ -80,7 +79,7 @@ static zend_always_inline void zend_object_release(zend_object *obj)
}
}
-static zend_always_inline size_t zend_object_properties_size(zend_class_entry *ce)
+static zend_always_inline size_t zend_object_properties_size(const zend_class_entry *ce)
{
return sizeof(zval) *
(ce->default_properties_count -
@@ -90,7 +89,7 @@ static zend_always_inline size_t zend_object_properties_size(zend_class_entry *c
/* Allocates object type and zeros it, but not the standard zend_object and properties.
* Standard object MUST be initialized using zend_object_std_init().
* Properties MUST be initialized using object_properties_init(). */
-static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
+static zend_always_inline void *zend_object_alloc(size_t obj_size, const zend_class_entry *ce) {
void *obj = emalloc(obj_size + zend_object_properties_size(ce));
memset(obj, 0, obj_size - sizeof(zend_object));
return obj;
@@ -137,6 +136,11 @@ static inline zend_property_info *zend_get_typed_property_info_for_slot(zend_obj
return NULL;
}
+static zend_always_inline zend_class_entry *zend_get_function_root_class(const zend_function *fbc)
+{
+ return fbc->common.prototype ? fbc->common.prototype->common.scope : fbc->common.scope;
+}
+
static zend_always_inline bool zend_check_method_accessible(const zend_function *fn, const zend_class_entry *scope)
{
if (!(fn->common.fn_flags & ZEND_ACC_PUBLIC)
diff --git a/Zend/zend_observer.c b/Zend/zend_observer.c
index 15722eb6b2eb..1cb4373f4c07 100644
--- a/Zend/zend_observer.c
+++ b/Zend/zend_observer.c
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at . |
+ | |
+ | SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Authors: Levi Morrison |
| Sammy Kaye Powers |
@@ -115,8 +114,8 @@ ZEND_API void zend_observer_shutdown(void)
static void zend_observer_fcall_install(zend_execute_data *execute_data)
{
- zend_llist *list = &zend_observers_fcall_list;
- zend_function *function = execute_data->func;
+ const zend_llist *list = &zend_observers_fcall_list;
+ const zend_function *function = execute_data->func;
ZEND_ASSERT(RUN_TIME_CACHE(&function->common));
zend_observer_fcall_begin_handler *begin_handlers = ZEND_OBSERVER_DATA(function), *begin_handlers_start = begin_handlers;
@@ -126,7 +125,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data)
*end_handlers = ZEND_OBSERVER_NOT_OBSERVED;
bool has_handlers = false;
- for (zend_llist_element *element = list->head; element; element = element->next) {
+ for (const zend_llist_element *element = list->head; element; element = element->next) {
zend_observer_fcall_init init;
memcpy(&init, element->data, sizeof init);
zend_observer_fcall_handlers handlers = init(execute_data);
@@ -157,7 +156,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data)
* the previous next handler is now at the place where the current handler was.
* Hence, the next handler executed will be the one after the next handler.
* Callees must thus invoke the next handler themselves, with the same arguments they were passed. */
-static bool zend_observer_remove_handler(void **first_handler, void *old_handler, void **next_handler) {
+static bool zend_observer_remove_handler(void **first_handler, const void *old_handler, void **next_handler) {
size_t registered_observers = zend_observers_fcall_list.count;
void **last_handler = first_handler + registered_observers - 1;
@@ -168,7 +167,7 @@ static bool zend_observer_remove_handler(void **first_handler, void *old_handler
*next_handler = NULL;
} else {
if (cur_handler != last_handler) {
- memmove(cur_handler, cur_handler + 1, sizeof(cur_handler) * (last_handler - cur_handler));
+ memmove(cur_handler, cur_handler + 1, sizeof(*cur_handler) * (last_handler - cur_handler));
}
*last_handler = NULL;
*next_handler = *cur_handler;
@@ -179,7 +178,7 @@ static bool zend_observer_remove_handler(void **first_handler, void *old_handler
return false;
}
-ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin) {
+ZEND_API void zend_observer_add_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin) {
size_t registered_observers = zend_observers_fcall_list.count;
zend_observer_fcall_begin_handler *first_handler = ZEND_OBSERVER_DATA(function), *last_handler = first_handler + registered_observers - 1;
if (*first_handler == ZEND_OBSERVER_NOT_OBSERVED || *first_handler == ZEND_OBSERVER_NONE_OBSERVED) {
@@ -196,7 +195,7 @@ ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_obse
}
}
-ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) {
+ZEND_API bool zend_observer_remove_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) {
void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function);
if (zend_observer_remove_handler(begin_handlers, begin, (void**)next)) {
// Ensure invariant: ZEND_OBSERVER_NONE_OBSERVED in begin_handlers if both are not observed
@@ -211,7 +210,7 @@ ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_o
return false;
}
-ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end) {
+ZEND_API void zend_observer_add_end_handler(const zend_function *function, zend_observer_fcall_end_handler end) {
size_t registered_observers = zend_observers_fcall_list.count;
void **begin_handler = (void **)ZEND_OBSERVER_DATA(function);
zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)begin_handler + registered_observers;
@@ -219,14 +218,14 @@ ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observ
if (*end_handler != ZEND_OBSERVER_NOT_OBSERVED) {
// there's no space for new handlers, then it's forbidden to call this function
ZEND_ASSERT(end_handler[registered_observers - 1] == NULL);
- memmove(end_handler + 1, end_handler, sizeof(end_handler) * (registered_observers - 1));
+ memmove(end_handler + 1, end_handler, sizeof(*end_handler) * (registered_observers - 1));
} else if (*begin_handler == ZEND_OBSERVER_NONE_OBSERVED) {
*begin_handler = ZEND_OBSERVER_NOT_OBSERVED;
}
*end_handler = end;
}
-ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) {
+ZEND_API bool zend_observer_remove_end_handler(const zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) {
size_t registered_observers = zend_observers_fcall_list.count;
void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function);
void **end_handlers = begin_handlers + registered_observers;
@@ -241,7 +240,7 @@ ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_obs
}
static inline zend_execute_data **prev_observed_frame(zend_execute_data *execute_data) {
- zend_function *func = EX(func);
+ const zend_function *func = EX(func);
ZEND_ASSERT(func);
return (zend_execute_data **)&Z_PTR_P(EX_VAR_NUM((ZEND_USER_CODE(func->type) ? func->op_array.last_var : ZEND_CALL_NUM_ARGS(execute_data)) + func->common.T - 1));
}
@@ -256,7 +255,7 @@ static void ZEND_FASTCALL _zend_observe_fcall_begin(zend_execute_data *execute_d
ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_data *execute_data, zend_observer_fcall_begin_handler *handler)
{
- zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count;
+ const zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count;
if (!*handler) {
zend_observer_fcall_install(execute_data);
@@ -265,7 +264,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_da
}
}
- zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)possible_handlers_end;
+ const zend_observer_fcall_end_handler *end_handler = (const zend_observer_fcall_end_handler *)possible_handlers_end;
if (*end_handler != ZEND_OBSERVER_NOT_OBSERVED) {
*prev_observed_frame(execute_data) = EG(current_observed_frame);
EG(current_observed_frame) = execute_data;
@@ -294,7 +293,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(zend_execute_data *execute
}
static inline void call_end_observers(zend_execute_data *execute_data, zval *return_value) {
- zend_function *func = EX(func);
+ const zend_function *func = EX(func);
ZEND_ASSERT(func);
zend_observer_fcall_end_handler *handler = (zend_observer_fcall_end_handler *)ZEND_OBSERVER_DATA(func) + zend_observers_fcall_list.count;
@@ -340,7 +339,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_function_declared_notify(zend_op_arra
return;
}
- for (zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) {
zend_observer_function_declared_cb callback = *(zend_observer_function_declared_cb *) (element->data);
callback(op_array, name);
}
@@ -358,7 +357,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_class_linked_notify(zend_class_entry
return;
}
- for (zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) {
zend_observer_class_linked_cb callback = *(zend_observer_class_linked_cb *) (element->data);
callback(ce, name);
}
@@ -372,7 +371,7 @@ ZEND_API void zend_observer_error_register(zend_observer_error_cb cb)
ZEND_API void _zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message)
{
- for (zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) {
zend_observer_error_cb callback = *(zend_observer_error_cb *) (element->data);
callback(type, error_filename, error_lineno, message);
}
@@ -395,12 +394,11 @@ ZEND_API void zend_observer_fiber_destroy_register(zend_observer_fiber_destroy_h
ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *initializing)
{
- zend_llist_element *element;
zend_observer_fiber_init_handler callback;
initializing->top_observed_frame = NULL;
- for (element = zend_observer_fiber_init.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_fiber_init.head; element; element = element->next) {
callback = *(zend_observer_fiber_init_handler *) element->data;
callback(initializing);
}
@@ -408,14 +406,13 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *
ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context *from, zend_fiber_context *to)
{
- zend_llist_element *element;
zend_observer_fiber_switch_handler callback;
if (from->status == ZEND_FIBER_STATUS_DEAD) {
zend_observer_fcall_end_all(); // fiber is either finished (call will do nothing) or has bailed out
}
- for (element = zend_observer_fiber_switch.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_fiber_switch.head; element; element = element->next) {
callback = *(zend_observer_fiber_switch_handler *) element->data;
callback(from, to);
}
@@ -426,10 +423,9 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context
ZEND_API void ZEND_FASTCALL zend_observer_fiber_destroy_notify(zend_fiber_context *destroying)
{
- zend_llist_element *element;
zend_observer_fiber_destroy_handler callback;
- for (element = zend_observer_fiber_destroy.head; element; element = element->next) {
+ for (const zend_llist_element *element = zend_observer_fiber_destroy.head; element; element = element->next) {
callback = *(zend_observer_fiber_destroy_handler *) element->data;
callback(destroying);
}
diff --git a/Zend/zend_observer.h b/Zend/zend_observer.h
index bb8964692c37..bcfba35c0658 100644
--- a/Zend/zend_observer.h
+++ b/Zend/zend_observer.h
@@ -2,15 +2,14 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright © Zend Technologies Ltd., a subsidiary company of |
+ | Perforce Software, Inc., and Contributors. |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.zend.com/license/2_00.txt. |
- | If you did not receive a copy of the Zend license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@zend.com so we can mail you a copy immediately. |
+ | This source file is subject to the Modified BSD License that is |
+ | bundled with this package in the file LICENSE, and is available |
+ | through the World Wide Web at