|
@@ -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..464c7e571d5b 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 |
@@ -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 d2952094a468..d70d08f5f1c4 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 {
@@ -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;
}
/* }}} */
@@ -2773,6 +2757,19 @@ static void emit_incompatible_trait_constant_error(
);
}
+static void emit_trait_constant_enum_case_conflict_error(
+ const zend_class_entry *ce, const zend_class_constant *trait_constant, zend_string *name
+) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Cannot use trait %s, because %s::%s conflicts with enum case %s::%s",
+ ZSTR_VAL(trait_constant->ce->name),
+ ZSTR_VAL(trait_constant->ce->name),
+ ZSTR_VAL(name),
+ ZSTR_VAL(ce->name),
+ ZSTR_VAL(name)
+ );
+}
+
static bool do_trait_constant_check(
zend_class_entry *ce, zend_class_constant *trait_constant, zend_string *name, zend_class_entry **traits, size_t current_trait
) {
@@ -2786,6 +2783,11 @@ static bool do_trait_constant_check(
zend_class_constant *existing_constant = Z_PTR_P(zv);
+ if (UNEXPECTED(ZEND_CLASS_CONST_FLAGS(existing_constant) & ZEND_CLASS_CONST_IS_CASE)) {
+ emit_trait_constant_enum_case_conflict_error(ce, trait_constant, name);
+ return false;
+ }
+
if ((ZEND_CLASS_CONST_FLAGS(trait_constant) & flags_mask) != (ZEND_CLASS_CONST_FLAGS(existing_constant) & flags_mask)) {
emit_incompatible_trait_constant_error(ce, existing_constant, trait_constant, name, traits, current_trait);
return false;
@@ -3315,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));
}
@@ -3610,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 689e76794df3..99df90486632 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,13 @@ 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)
{
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;
}
@@ -585,7 +584,7 @@ static const char *zend_ini_consume_quantity_prefix(const char *const digits, co
++digits_consumed;
}
- if (digits_consumed[0] == '0' && !isdigit(digits_consumed[1])) {
+ if (digits_consumed[0] == '0' && !isdigit((unsigned char)digits_consumed[1])) {
/* Value is just 0 */
if ((digits_consumed+1) == str_end) {
return digits_consumed;
@@ -610,12 +609,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};
@@ -643,7 +642,7 @@ static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_
}
/* if there is no digit after +/- */
- if (!isdigit(digits[0])) {
+ if (!isdigit((unsigned char)digits[0])) {
/* Escape the string to avoid null bytes and to make non-printable chars
* visible */
smart_str_append_escaped(&invalid, ZSTR_VAL(value), ZSTR_LEN(value));
@@ -657,7 +656,7 @@ static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_
}
int base = 0;
- if (digits[0] == '0' && !isdigit(digits[1])) {
+ if (digits[0] == '0' && !isdigit((unsigned char)digits[1])) {
/* Value is just 0 */
if ((digits+1) == str_end) {
*errstr = NULL;
@@ -844,19 +843,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 +869,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 +885,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 +905,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 +932,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 +955,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 +963,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 +976,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 +985,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 +993,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 +1005,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 +1013,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 +1025,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