[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 25 Sep 2026 08:18:16 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141523@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Date: 2026-09-25T10:18:08+02:00 Commit: https://github.com/php/php-src/commit/f468bf0af8a7e3a98d44cd45553b966c3997c13c Raw diff: https://github.com/php/php-src/commit/f468bf0af8a7e3a98d44cd45553b966c3997c13c.diff Merge branch 'PHP-8.6' * PHP-8.6: zend_compile: Disable array_map() optimization for strict_types=1 (#23889) Changed paths: A ext/opcache/tests/array_map_foreach_optimization_009.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0ced55283868..bad60a5f1071 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5324,6 +5324,12 @@ static zend_result zend_compile_func_clone(znode *result, const zend_ast_list *a static zend_result zend_compile_func_array_map(znode *result, zend_ast_list *args, zend_string *lcname, uint32_t lineno) /* {{{ */ { + /* array_map() as an internal function calls the callback as if strict_types=0, + * this optimization is therefore not legal if strict_types=1. */ + if (CG(active_op_array)->fn_flags & ZEND_ACC_STRICT_TYPES) { + return FAILURE; + } + /* Bail out if we do not have exactly two parameters. */ if (args->children != 2) { return FAILURE; diff --git a/ext/opcache/tests/array_map_foreach_optimization_009.phpt b/ext/opcache/tests/array_map_foreach_optimization_009.phpt new file mode 100644 index 000000000000..a1552c44f793 --- /dev/null +++ b/ext/opcache/tests/array_map_foreach_optimization_009.phpt @@ -0,0 +1,35 @@ +--TEST-- +array_map(): foreach optimization requires strict_types=0 (GH-23882) +--EXTENSIONS-- +opcache +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.opt_debug_level=0x20000 +--FILE-- +<?php + +declare(strict_types=1); + +var_dump(array_map(trim(...), [1])); + +?> +--EXPECTF-- +$_main: + ; (lines=%d, args=0, vars=%d, tmps=%d) + ; (after optimizer) + ; %s +0000 INIT_FCALL 1 %d string("var_dump") +0001 INIT_FCALL 2 %d string("array_map") +0002 INIT_FCALL 0 %d string("trim") +0003 T0 = CALLABLE_CONVERT %d +0004 SEND_VAL T0 1 +0005 SEND_VAL array(...) 2 +0006 T0 = DO_ICALL +0007 SEND_VAL T0 1 +0008 DO_ICALL +0009 RETURN int(1) +array(1) { + [0]=> + string(1) "1" +}

« previous php.cvs (#141523) next »