From e3dd8d5cff89deba704807872239715c68b6e567 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sun, 9 Aug 2026 15:16:12 +0700 Subject: [PATCH] ext/standard: improved tests Follow up to: #23019. --- Zend/tests/named_params/internal_variadics.phpt | 16 ++++++++-------- .../tests/array/array_intersect_empty.phpt | 4 ++-- .../array/array_intersect_side_effects.phpt | 4 ++-- .../tests/array/array_intersect_values.phpt | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) 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