Skip to content

[pull] master from php:master #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.5.0alpha2

- Standard:
. Optimized pack(). (nielsdos, divinity76)

- URI:
. Return the singleton UrlValidationErrorType instances from Uri\WhatWg\Url
instead of creating new objects that are different from the singleton.
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ PHP 8.5 UPGRADE NOTES
4. Deprecated Functionality
========================================

- Core:
. Returning a non-string from a user output handler is deprecated. The
deprecation warning will bypass the handler with the bad return to ensure
it is visible; if there are nested output handlers the next one will still
be used.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4

- Hash:
. The MHASH_* constants have been deprecated. These have been overlooked
when the mhash*() function family has been deprecated per
Expand Down Expand Up @@ -619,6 +626,7 @@ PHP 8.5 UPGRADE NOTES
. Improved performance of urlencode() and rawurlencode().
. Improved unpack() performance with nameless repetitions by avoiding
creating temporary strings and reparsing them.
. Improved pack() performance.

- XMLReader:
. Improved property access performance.
Expand Down
18 changes: 18 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,28 @@ PHP 8.5 INTERNALS UPGRADE NOTES
. Added the zend_update_exception_properties() function for instantiating
Exception child classes. It updates the $message, $code, and $previous
properties.
. zend_exception_get_default() was removed, use zend_ce_exception directly.
. zend_get_error_exception() was removed, use zend_ce_error_exception
directly.
. ZEND_IS_XDIGIT() macro was removed because it was unused and its name
did not match its actual behavior.
. The following zend_string-related legacy aliases were removed:
* IS_INTERNED() - use ZSTR_IS_INTERNED()
* STR_EMPTY_ALLOC() - use ZSTR_EMPTY_ALLOC()
* _STR_HEADER_SIZE - use _ZSTR_HEADER_SIZE
* STR_ALLOCA_ALLOC() - use ZSTR_ALLOCA_ALLOC()
* STR_ALLOCA_INIT() - use ZSTR_ALLOCA_INIT()
* STR_ALLOCA_FREE() - use ZSTR_ALLOCA_FREE()
. zend_register_constant() now returns a pointer to the added constant
on success and NULL on failure instead of SUCCESS/FAILURE.
The specialized registration methods that previously had void returns
also return pointers to the added constants:
* zend_register_bool_constant()
* zend_register_null_constant()
* zend_register_long_constant()
* zend_register_double_constant()
* zend_register_string_constant()
* zend_register_stringl_constant()

========================
2. Build system changes
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/concat/bug79836.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $counter = 0;
ob_start(function ($buffer) use (&$c, &$counter) {
$c = 0;
++$counter;
return '';
}, 1);
$c .= [];
$c .= [];
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/concat/bug79836_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ opcache.optimization_level = 0x7FFEBFFF & ~0x400
$x = 'non-empty';
ob_start(function () use (&$c) {
$c = 0;
return '';
}, 1);
$c = [];
$x = $c . $x;
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/concat/bug79836_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ $c = str_repeat("abcd", 10);

ob_start(function () use (&$c) {
$c = 0;
return '';
}, 1);

class X {
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/declare/gh18033_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ob_start(function() {
register_tick_function(
function() { }
);
return '';
});
?>
--EXPECT--
1 change: 1 addition & 0 deletions Zend/tests/gh11189.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ob_start(function() {
$a[] = 2;
}
fwrite(STDOUT, "Success");
return '';
});

$a = [];
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/gh11189_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ob_start(function() {
$a[] = 2;
}
fwrite(STDOUT, "Success");
return '';
});

$a = ["not packed" => 1];
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/gh16408.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ $counter = 0;
ob_start(function ($buffer) use (&$c, &$counter) {
$c = 0;
++$counter;
return '';
}, 1);
$c .= [];
$c .= [];
Expand Down
28 changes: 12 additions & 16 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -4021,13 +4021,11 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_
((fcc->object && fcc->calling_scope->__call) ||
(!fcc->object && fcc->calling_scope->__callstatic)))) {
scope = get_scope(frame);
if (fcc->function_handler->common.scope != scope) {
if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE)
|| !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) {
retval = 0;
fcc->function_handler = NULL;
goto get_function_via_handler;
}
ZEND_ASSERT(!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC));
if (!zend_check_method_accessible(fcc->function_handler, scope)) {
retval = 0;
fcc->function_handler = NULL;
goto get_function_via_handler;
}
}
} else {
Expand Down Expand Up @@ -4086,17 +4084,15 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_
if (retval
&& !(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC)) {
scope = get_scope(frame);
if (fcc->function_handler->common.scope != scope) {
if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE)
|| (!zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope))) {
if (error) {
if (*error) {
efree(*error);
}
zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
ZEND_ASSERT(!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC));
if (!zend_check_method_accessible(fcc->function_handler, scope)) {
if (error) {
if (*error) {
efree(*error);
}
retval = 0;
zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
}
retval = 0;
}
}
}
Expand Down
21 changes: 7 additions & 14 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,21 +1098,14 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
} else {
fptr = zend_hash_find_ptr_lc(&ce->function_table, method_name);
if (fptr) {
if (!(fptr->common.fn_flags & ZEND_ACC_PUBLIC)) {
if (UNEXPECTED(fptr->common.scope != scope)) {
if (
UNEXPECTED(fptr->op_array.fn_flags & ZEND_ACC_PRIVATE)
|| UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fptr), scope))
) {
if (ce->__callstatic) {
zend_throw_error(NULL, "Creating a callable for the magic __callStatic() method is not supported in constant expressions");
} else {
zend_bad_method_call(fptr, method_name, scope);
}

return FAILURE;
}
if (!zend_check_method_accessible(fptr, scope)) {
if (ce->__callstatic) {
zend_throw_error(NULL, "Creating a callable for the magic __callStatic() method is not supported in constant expressions");
} else {
zend_bad_method_call(fptr, method_name, scope);
}

return FAILURE;
}
} else {
if (ce->__callstatic) {
Expand Down
19 changes: 4 additions & 15 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ ZEND_FUNCTION(clone)
RETURN_THROWS();
}

if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) {
if (clone->common.scope != scope) {
if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE)
|| UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) {
zend_bad_method_call(clone, clone->common.function_name, scope);
RETURN_THROWS();
}
}
if (clone && !zend_check_method_accessible(clone, scope)) {
zend_bad_method_call(clone, clone->common.function_name, scope);
RETURN_THROWS();
}

zend_object *cloned;
Expand Down Expand Up @@ -953,13 +948,7 @@ ZEND_FUNCTION(get_class_methods)
scope = zend_get_executed_scope();

ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, mptr) {
if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC)
|| (scope &&
(((mptr->common.fn_flags & ZEND_ACC_PROTECTED) &&
zend_check_protected(mptr->common.scope, scope))
|| ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
scope == mptr->common.scope)))
) {
if (zend_check_method_accessible(mptr, scope)) {
ZVAL_STR_COPY(&method_name, mptr->common.function_name);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
}
Expand Down
24 changes: 12 additions & 12 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,62 +136,62 @@ void zend_register_standard_constants(void)
null_const = zend_hash_str_find_ptr(EG(zend_constants), "NULL", sizeof("NULL")-1);
}

ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number)
ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number)
{
zend_constant c;

ZVAL_NULL(&c.value);
ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number);
c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT);
zend_register_constant(&c);
return zend_register_constant(&c);
}

ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number)
ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number)
{
zend_constant c;

ZVAL_BOOL(&c.value, bval);
ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number);
c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT);
zend_register_constant(&c);
return zend_register_constant(&c);
}

ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number)
ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number)
{
zend_constant c;

ZVAL_LONG(&c.value, lval);
ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number);
c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT);
zend_register_constant(&c);
return zend_register_constant(&c);
}


ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number)
ZEND_API zend_constant *zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number)
{
zend_constant c;

ZVAL_DOUBLE(&c.value, dval);
ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number);
c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT);
zend_register_constant(&c);
return zend_register_constant(&c);
}


ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number)
ZEND_API zend_constant *zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number)
{
zend_constant c;

ZVAL_STR(&c.value, zend_string_init_interned(strval, strlen, flags & CONST_PERSISTENT));
ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number);
c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT);
zend_register_constant(&c);
return zend_register_constant(&c);
}


ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number)
ZEND_API zend_constant *zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number)
{
zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number);
return zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number);
}

static zend_constant *zend_get_halt_offset_constant(const char *name, size_t name_len)
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name);
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
ZEND_API zend_constant *zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
ZEND_API zend_constant *zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
ZEND_API zend_constant *zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
ZEND_API zend_constant *zend_register_constant(zend_constant *c);
void zend_constant_add_attributes(zend_constant *c, HashTable *attributes);
#ifdef ZTS
Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_constants_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,20 +846,6 @@ void zend_register_default_exception(void) /* {{{ */
}
/* }}} */

/* {{{ Deprecated - Use zend_ce_exception directly instead */
ZEND_API zend_class_entry *zend_exception_get_default(void)
{
return zend_ce_exception;
}
/* }}} */

/* {{{ Deprecated - Use zend_ce_error_exception directly instead */
ZEND_API zend_class_entry *zend_get_error_exception(void)
{
return zend_ce_error_exception;
}
/* }}} */

static zend_object *zend_throw_exception_zstr(zend_class_entry *exception_ce, zend_string *message, zend_long code) /* {{{ */
{
zval ex, tmp;
Expand Down
6 changes: 0 additions & 6 deletions Zend/zend_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ void zend_register_default_exception(void);

ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object);

/* Deprecated - Use zend_ce_exception directly instead */
ZEND_API zend_class_entry *zend_exception_get_default(void);

/* Deprecated - Use zend_ce_error_exception directly instead */
ZEND_API zend_class_entry *zend_get_error_exception(void);

ZEND_API void zend_register_default_classes(void);

/* exception_ce NULL, zend_ce_exception, zend_ce_error, or a derived class
Expand Down
Loading