[php-src] master: ext/standard: improved tests (#23184)

NickSdot via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2026-08-10T21:24:29+01:00

Commit: https://github.com/php/php-src/commit/ff7ef3c858fc54f8b62c1d274ce638523e202f09
Raw diff: https://github.com/php/php-src/commit/ff7ef3c858fc54f8b62c1d274ce638523e202f09.diff

ext/standard: improved tests (#23184)

Changed paths:
  M  Zend/tests/named_params/internal_variadics.phpt
  M  ext/standard/tests/array/array_intersect_empty.phpt
  M  ext/standard/tests/array/array_intersect_side_effects.phpt
  M  ext/standard/tests/array/array_intersect_values.phpt


Diff:

diff --git a/Zend/tests/named_params/internal_variadics.phpt b/Zend/tests/named_params/internal_variadics.phpt
index 8ec11ac2c34a..ac5b629ccaae 100644
--- a/Zend/tests/named_params/internal_variadics.phpt
+++ b/Zend/tests/named_params/internal_variadics.phpt
@@ -6,13 +6,13 @@ Named params on internal functions: Variadic functions that don't support extra
 try {
     array_merge([1, 2], a: [3, 4]);
 } catch (ArgumentCountError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     array_diff_key([1, 2], [3, 4], a: [5, 6]);
 } catch (ArgumentCountError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 var_dump(array_intersect(array: [1, 2]) === [1, 2]);
@@ -20,19 +20,19 @@ var_dump(array_intersect(array: [1, 2]) === [1, 2]);
 try {
     array_intersect([1, 2], arrays: [2]);
 } catch (ArgumentCountError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     $array = [1, 2];
     array_push($array, ...['values' => 3]);
 } catch (ArgumentCountError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-Internal function array_merge() does not accept named variadic arguments
-Internal function array_diff_key() does not accept named variadic arguments
+ArgumentCountError: Internal function array_merge() does not accept named variadic arguments
+ArgumentCountError: Internal function array_diff_key() does not accept named variadic arguments
 bool(true)
-Internal function array_intersect() does not accept named variadic arguments
-Internal function array_push() does not accept named variadic arguments
+ArgumentCountError: Internal function array_intersect() does not accept named variadic arguments
+ArgumentCountError: Internal function array_push() does not accept named variadic arguments
diff --git a/ext/standard/tests/array/array_intersect_empty.phpt b/ext/standard/tests/array/array_intersect_empty.phpt
index 1bf527a42694..ab5ae218b7c4 100644
--- a/ext/standard/tests/array/array_intersect_empty.phpt
+++ b/ext/standard/tests/array/array_intersect_empty.phpt
@@ -36,7 +36,7 @@ var_dump(array_keys($result));
 try {
     array_intersect([], [], new stdClass());
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
@@ -52,4 +52,4 @@ array(1) {
   [0]=>
   int(10)
 }
-array_intersect(): Argument #3 must be of type array, stdClass given
+TypeError: array_intersect(): Argument #3 must be of type array, stdClass given
diff --git a/ext/standard/tests/array/array_intersect_side_effects.phpt b/ext/standard/tests/array/array_intersect_side_effects.phpt
index 00cacb9b4a39..6c2a2451fdc6 100644
--- a/ext/standard/tests/array/array_intersect_side_effects.phpt
+++ b/ext/standard/tests/array/array_intersect_side_effects.phpt
@@ -47,7 +47,7 @@ set_error_handler(static function (int $code, string $message): bool {
 try {
     array_intersect([[1], [2]], ['Array'], new stdClass());
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 restore_error_handler();
@@ -67,4 +67,4 @@ array(2) {
   [1]=>
   string(4) "keep"
 }
-array_intersect(): Argument #3 must be of type array, stdClass given
+TypeError: array_intersect(): Argument #3 must be of type array, stdClass given
diff --git a/ext/standard/tests/array/array_intersect_values.phpt b/ext/standard/tests/array/array_intersect_values.phpt
index caac782346b0..53234e103cbb 100644
--- a/ext/standard/tests/array/array_intersect_values.phpt
+++ b/ext/standard/tests/array/array_intersect_values.phpt
@@ -67,13 +67,13 @@ class ThrowingStringableValue {
 try {
     array_intersect(['value'], [new ThrowingStringableValue(), 'value']);
 } catch (RuntimeException $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     array_intersect([''], [new stdClass()]);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 set_error_handler(static function (int $code, string $message): never {
@@ -82,7 +82,7 @@ set_error_handler(static function (int $code, string $message): never {
 try {
     array_intersect([[1]], [[2]]);
 } catch (ErrorException $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 } finally {
     restore_error_handler();
 }
@@ -98,6 +98,6 @@ bool(true)
 bool(true)
 null,false,true,zero-float,float,resource,object
 bool(true)
-conversion failed
-Object of class stdClass could not be converted to string
-Array to string conversion
+RuntimeException: conversion failed
+Error: Object of class stdClass could not be converted to string
+ErrorException: Array to string conversion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.