[php-src] master: Merge branch 'PHP-8.6'
| From: | Jorg Sowa | Date: | Sun, 08 Nov 2026 15:58:24 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143445@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-11-08T16:54:26+01:00
Commit: https://github.com/php/php-src/commit/ff481155ec705ae4f39b59254a67792fb58b68bb
Raw diff: https://github.com/php/php-src/commit/ff481155ec705ae4f39b59254a67792fb58b68bb.diff
Merge branch 'PHP-8.6'
# Conflicts:
# NEWS
Changed paths:
A ext/opcache/tests/jit/add_array_element_null_key.phpt
A ext/opcache/tests/jit/array_key_exists_null_key.phpt
A ext/opcache/tests/jit/assign_dim_null_key.phpt
A ext/opcache/tests/jit/fetch_dim_is_null_key.phpt
A ext/opcache/tests/jit/fetch_dim_w_null_key.phpt
A ext/opcache/tests/jit/gh25269.phpt
A ext/opcache/tests/jit/isset_isempty_dim_obj_null_key.phpt
A ext/opcache/tests/opt/dce_023.phpt
A ext/opcache/tests/opt/dce_024.phpt
A ext/opcache/tests/opt/dce_025.phpt
A ext/opcache/tests/opt/dce_026.phpt
A ext/opcache/tests/opt/dce_027.phpt
M Zend/Optimizer/zend_inference.c
Diff:
diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c
index 264b7022a036..896cb24a190a 100644
--- a/Zend/Optimizer/zend_inference.c
+++ b/Zend/Optimizer/zend_inference.c
@@ -4939,7 +4939,7 @@ ZEND_API zend_result zend_ssa_inference(zend_arena **arena, const
zend_op_array
/* }}} */
/* Key types whose conversion to an array offset may emit a diagnostic */
-#define MAY_BE_THROWING_KEY (MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
+#define MAY_BE_THROWING_KEY (MAY_BE_NULL|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const
zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2)
{
@@ -5290,7 +5290,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op
*ssa_op
case ZEND_INIT_ARRAY:
return (opline->op2_type != IS_UNUSED) && (t2 & MAY_BE_THROWING_KEY);
case ZEND_ADD_ARRAY_ELEMENT:
- return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_NULL|MAY_BE_THROWING_KEY));
+ return (opline->op2_type == IS_UNUSED) || (t2 & MAY_BE_THROWING_KEY);
case ZEND_STRLEN:
return (t1 & MAY_BE_ANY) != MAY_BE_STRING;
case ZEND_COUNT:
diff --git a/ext/opcache/tests/jit/add_array_element_null_key.phpt
b/ext/opcache/tests/jit/add_array_element_null_key.phpt
new file mode 100644
index 000000000000..3b535d93fc6b
--- /dev/null
+++ b/ext/opcache/tests/jit/add_array_element_null_key.phpt
@@ -0,0 +1,27 @@
+--TEST--
+JIT ADD_ARRAY_ELEMENT: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ var_dump([0, $k => 1]);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/jit/array_key_exists_null_key.phpt
b/ext/opcache/tests/jit/array_key_exists_null_key.phpt
new file mode 100644
index 000000000000..4f0b2f25e6af
--- /dev/null
+++ b/ext/opcache/tests/jit/array_key_exists_null_key.phpt
@@ -0,0 +1,27 @@
+--TEST--
+JIT ARRAY_KEY_EXISTS: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ var_dump(array_key_exists($k, []));
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as the key parameter for array_key_exists() is deprecated, use an empty
string instead
diff --git a/ext/opcache/tests/jit/assign_dim_null_key.phpt
b/ext/opcache/tests/jit/assign_dim_null_key.phpt
new file mode 100644
index 000000000000..bb255df6a6c7
--- /dev/null
+++ b/ext/opcache/tests/jit/assign_dim_null_key.phpt
@@ -0,0 +1,28 @@
+--TEST--
+JIT ASSIGN_DIM: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [];
+ var_dump($a[$k] = 1);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/jit/fetch_dim_is_null_key.phpt
b/ext/opcache/tests/jit/fetch_dim_is_null_key.phpt
new file mode 100644
index 000000000000..2a09da67e177
--- /dev/null
+++ b/ext/opcache/tests/jit/fetch_dim_is_null_key.phpt
@@ -0,0 +1,28 @@
+--TEST--
+JIT FETCH_DIM_IS: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [];
+ var_dump($a[$k] ?? 0);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/jit/fetch_dim_w_null_key.phpt
b/ext/opcache/tests/jit/fetch_dim_w_null_key.phpt
new file mode 100644
index 000000000000..3ec27c5893a2
--- /dev/null
+++ b/ext/opcache/tests/jit/fetch_dim_w_null_key.phpt
@@ -0,0 +1,37 @@
+--TEST--
+JIT FETCH_DIM_W: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+class C {
+ function __destruct() {
+ echo "destruct\n";
+ }
+}
+
+function g($x, &$y) {}
+
+function test(null $k) {
+ $c = new C;
+ g($c, $a[$k]);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+destruct
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/jit/gh25269.phpt b/ext/opcache/tests/jit/gh25269.phpt
new file mode 100644
index 000000000000..9a260491945e
--- /dev/null
+++ b/ext/opcache/tests/jit/gh25269.phpt
@@ -0,0 +1,27 @@
+--TEST--
+GH-25269 (JIT: misaligned zval passed to ZEND_ADD_ARRAY_ELEMENT handler)
+--CREDITS--
+YuanchengJiang
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit_buffer_size=64M
+opcache.jit=function
+--FILE--
+<?php
+set_error_handler(function($errno, $errstr) {
+ throw new ErrorException($errstr);
+});
+function test() {
+ return [null => 1, "a" => 2, "b" => 3];
+}
+try {
+ test();
+} catch (ErrorException $e) {
+ echo $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/jit/isset_isempty_dim_obj_null_key.phpt
b/ext/opcache/tests/jit/isset_isempty_dim_obj_null_key.phpt
new file mode 100644
index 000000000000..2b84e5a4ad61
--- /dev/null
+++ b/ext/opcache/tests/jit/isset_isempty_dim_obj_null_key.phpt
@@ -0,0 +1,28 @@
+--TEST--
+JIT ISSET_ISEMPTY_DIM_OBJ: null key conversion may throw
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [];
+ var_dump(isset($a[$k]));
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/opt/dce_023.phpt b/ext/opcache/tests/opt/dce_023.phpt
new file mode 100644
index 000000000000..ffb4f3ba846e
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_023.phpt
@@ -0,0 +1,27 @@
+--TEST--
+DCE must not remove ASSIGN_DIM with a null key
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a[$k] = 1;
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/opt/dce_024.phpt b/ext/opcache/tests/opt/dce_024.phpt
new file mode 100644
index 000000000000..5db1400c9950
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_024.phpt
@@ -0,0 +1,27 @@
+--TEST--
+DCE must not remove INIT_ARRAY with a null key
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [$k => 1];
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/opt/dce_025.phpt b/ext/opcache/tests/opt/dce_025.phpt
new file mode 100644
index 000000000000..16d31607644e
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_025.phpt
@@ -0,0 +1,27 @@
+--TEST--
+DCE must not remove ARRAY_KEY_EXISTS with a null key
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ array_key_exists($k, []);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as the key parameter for array_key_exists() is deprecated, use an empty
string instead
diff --git a/ext/opcache/tests/opt/dce_026.phpt b/ext/opcache/tests/opt/dce_026.phpt
new file mode 100644
index 000000000000..b582063f7b24
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_026.phpt
@@ -0,0 +1,28 @@
+--TEST--
+DCE must not remove ISSET_ISEMPTY_DIM_OBJ with a null key
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [];
+ isset($a[$k]);
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead
diff --git a/ext/opcache/tests/opt/dce_027.phpt b/ext/opcache/tests/opt/dce_027.phpt
new file mode 100644
index 000000000000..a96136215409
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_027.phpt
@@ -0,0 +1,28 @@
+--TEST--
+DCE must not remove FETCH_DIM_IS with a null key
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+function test(null $k) {
+ $a = [];
+ $a[$k] ?? 0;
+}
+
+try {
+ test(null);
+} catch (Exception $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Using null as an array offset is deprecated, use an empty string instead