Commit faf555d6c01 for php
commit faf555d6c019e6f4325e1a03662eb15b37f42835
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Tue Dec 1 06:44:04 2026 +0700
ext/standard: Removes ZPP tests (#23837)
* review: remove redundant ZPP tests
* review: remove pointless test
* review: remove redundant ZPP test cases
diff --git a/ext/standard/tests/file/flock_error.phpt b/ext/standard/tests/file/flock_error.phpt
index cb4186eccf9..e109174c24e 100644
--- a/ext/standard/tests/file/flock_error.phpt
+++ b/ext/standard/tests/file/flock_error.phpt
@@ -13,33 +13,6 @@
$file = preg_replace("~\.phpt?$~", '.tmp', __FILE__);
$fp = fopen($file, "w");
-
-/* array of operations */
-$operations = array(
- 0,
- LOCK_NB,
- FALSE,
- array(1,2,3),
- array(),
- "string",
- "",
- "\0"
-);
-
-$i = 0;
-foreach($operations as $operation) {
- echo "--- Iteration $i ---" . \PHP_EOL;
- try {
- var_dump(flock($fp, $operation));
- } catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
- }
- $i++;
-}
-
-
-/* Invalid arguments */
-$fp = fopen($file, "w");
fclose($fp);
try {
var_dump(flock($fp, LOCK_SH|LOCK_NB));
@@ -54,20 +27,4 @@
?>
--EXPECT--
*** Testing error conditions ***
---- Iteration 0 ---
-ValueError: flock(): Argument #2 ($operation) must be one of LOCK_SH, LOCK_EX, or LOCK_UN
---- Iteration 1 ---
-ValueError: flock(): Argument #2 ($operation) must be one of LOCK_SH, LOCK_EX, or LOCK_UN
---- Iteration 2 ---
-ValueError: flock(): Argument #2 ($operation) must be one of LOCK_SH, LOCK_EX, or LOCK_UN
---- Iteration 3 ---
-TypeError: flock(): Argument #2 ($operation) must be of type int, array given
---- Iteration 4 ---
-TypeError: flock(): Argument #2 ($operation) must be of type int, array given
---- Iteration 5 ---
-TypeError: flock(): Argument #2 ($operation) must be of type int, string given
---- Iteration 6 ---
-TypeError: flock(): Argument #2 ($operation) must be of type int, string given
---- Iteration 7 ---
-TypeError: flock(): Argument #2 ($operation) must be of type int, string given
TypeError: flock(): Argument #1 ($stream) must be an open stream resource
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
index 008b7f6dc46..0512c472b97 100644
--- a/ext/standard/tests/file/tempnam_variation3.phpt
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
@@ -23,9 +23,6 @@
FALSE,
"",
" ",
- "\0",
- array(),
-
/* prefix with path separator of a non existing directory*/
"/no/such/file/dir",
"php/php"
@@ -34,12 +31,7 @@
for( $i=0; $i<count($names_arr); $i++ ) {
echo "-- Iteration $i --\n";
- try {
- $file_name = tempnam("$file_path", $names_arr[$i]);
- } catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
- continue;
- }
+ $file_name = tempnam("$file_path", $names_arr[$i]);
/* creating the files in existing dir */
if( file_exists($file_name) ) {
@@ -97,14 +89,10 @@
File permissions are => 100600
File created in => directory specified
-- Iteration 5 --
-ValueError: tempnam(): Argument #2 ($prefix) must not contain any null bytes
--- Iteration 6 --
-TypeError: tempnam(): Argument #2 ($prefix) must be of type string, array given
--- Iteration 7 --
File name is => %s/dir%s
File permissions are => 100600
File created in => directory specified
--- Iteration 8 --
+-- Iteration 6 --
File name is => %s/php%s
File permissions are => 100600
File created in => directory specified
diff --git a/ext/standard/tests/file/tempnam_variation7.phpt b/ext/standard/tests/file/tempnam_variation7.phpt
index 6e8baec0d66..300673db321 100644
--- a/ext/standard/tests/file/tempnam_variation7.phpt
+++ b/ext/standard/tests/file/tempnam_variation7.phpt
@@ -21,9 +21,6 @@
FALSE,
"",
" ",
- "\0",
- array(),
-
/* Non-existing dirs */
"/no/such/file/dir",
"php"
@@ -32,12 +29,7 @@
for( $i=0; $i<count($names_arr); $i++ ) {
echo "-- Iteration $i --\n";
- try {
- $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
- } catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
- continue;
- }
+ $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
if( file_exists($file_name) ){
@@ -96,16 +88,12 @@
File permissions are => 100600
File created in => temp dir
-- Iteration 5 --
-ValueError: tempnam(): Argument #1 ($directory) must not contain any null bytes
--- Iteration 6 --
-TypeError: tempnam(): Argument #1 ($directory) must be of type string, array given
--- Iteration 7 --
Notice: tempnam(): file created in the system's temporary directory in %stempnam_variation7.php on line %d
File name is => %s/tempnam_variation3.tmp%s
File permissions are => 100600
File created in => temp dir
--- Iteration 8 --
+-- Iteration 6 --
Notice: tempnam(): file created in the system's temporary directory in %stempnam_variation7.php on line %d
File name is => %s/tempnam_variation3.tmp%s
diff --git a/ext/standard/tests/general_functions/register_tick_function_error.phpt b/ext/standard/tests/general_functions/register_tick_function_error.phpt
deleted file mode 100644
index 6b530ad2599..00000000000
--- a/ext/standard/tests/general_functions/register_tick_function_error.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-register_tick_function only accepts a valid callback as parameter
---FILE--
-<?php
-declare(ticks=1);
-
-try {
- register_tick_function("a");
-} catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
-}
-?>
---EXPECT--
-TypeError: register_tick_function(): Argument #1 ($callback) must be a valid callback, function "a" not found or invalid function name
diff --git a/ext/standard/tests/general_functions/unregister_tick_function_error.phpt b/ext/standard/tests/general_functions/unregister_tick_function_error.phpt
deleted file mode 100644
index 08e38f75e9c..00000000000
--- a/ext/standard/tests/general_functions/unregister_tick_function_error.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-unregister_tick_function only accepts a valid callback as parameter
---FILE--
-<?php
-declare(ticks=1);
-
-try {
- unregister_tick_function("a");
-} catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
-}
-?>
---EXPECT--
-TypeError: unregister_tick_function(): Argument #1 ($callback) must be a valid callback, function "a" not found or invalid function name
diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt
index bcc18bfa2c0..c191f810373 100644
--- a/ext/standard/tests/math/base_convert_variation1.phpt
+++ b/ext/standard/tests/math/base_convert_variation1.phpt
@@ -10,9 +10,6 @@
xyz
EOT;
-// get a resource variable
-$fp = fopen(__FILE__, "r");
-
$inputs = array(
// int data
/*1*/ 0,
@@ -37,15 +34,10 @@
// empty data
/*17*/ "",
'',
- array(),
-
// string data
/*20*/ "abcxyz",
'abcxyz',
$heredoc,
-
- // resource variable
-/*25*/ $fp
);
// loop through each element of $inputs to check the behaviour of base_convert()
@@ -59,7 +51,6 @@
}
$iterator++;
}
-fclose($fp);
?>
--EXPECTF--
*** Testing base_convert() : usage variations ***
@@ -113,16 +104,10 @@
string(1) "0"
-- Iteration 17 --
-TypeError: base_convert(): Argument #1 ($num) must be of type string, array given
+Exception: Invalid characters passed for attempted conversion
-- Iteration 18 --
Exception: Invalid characters passed for attempted conversion
-- Iteration 19 --
Exception: Invalid characters passed for attempted conversion
-
--- Iteration 20 --
-Exception: Invalid characters passed for attempted conversion
-
--- Iteration 21 --
-TypeError: base_convert(): Argument #1 ($num) must be of type string, resource given
diff --git a/ext/standard/tests/math/bindec_variation1_64bit.phpt b/ext/standard/tests/math/bindec_variation1_64bit.phpt
index 746cc12503e..417c751654f 100644
--- a/ext/standard/tests/math/bindec_variation1_64bit.phpt
+++ b/ext/standard/tests/math/bindec_variation1_64bit.phpt
@@ -14,9 +14,6 @@
xyz
EOT;
-// get a resource variable
-$fp = fopen(__FILE__, "r");
-
$inputs = array(
// int data
/*1*/ 0,
@@ -40,15 +37,11 @@
// empty data
/*16*/ "",
'',
- array(),
// string data
/*19*/ "abcxyz",
'abcxyz',
$heredoc,
-
- // resource variable
-/*24*/ $fp
);
// loop through each element of $inputs to check the behaviour of bindec()
@@ -62,7 +55,6 @@
}
$iterator++;
};
-fclose($fp);
?>
--EXPECTF--
*** Testing bindec() : usage variations ***
@@ -113,16 +105,10 @@
int(0)
-- Iteration 16 --
-TypeError: bindec(): Argument #1 ($binary_string) must be of type string, array given
+Exception: Invalid characters passed for attempted conversion
-- Iteration 17 --
Exception: Invalid characters passed for attempted conversion
-- Iteration 18 --
Exception: Invalid characters passed for attempted conversion
-
--- Iteration 19 --
-Exception: Invalid characters passed for attempted conversion
-
--- Iteration 20 --
-TypeError: bindec(): Argument #1 ($binary_string) must be of type string, resource given
diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt
index 26e1dd2f1c5..91cf9aa1336 100644
--- a/ext/standard/tests/math/decbin_basic.phpt
+++ b/ext/standard/tests/math/decbin_basic.phpt
@@ -11,17 +11,12 @@
"3950.5",
"3.9505e3",
"039",
- "0x5F",
true,
false,
);
foreach ($values as $value) {
- try {
- var_dump(decbin($value));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(decbin($value));
}
?>
@@ -43,6 +38,5 @@
Deprecated: Implicit conversion from float-string "3.9505e3" to int loses precision in %s on line %d
string(12) "111101101110"
string(6) "100111"
-TypeError: decbin(): Argument #1 ($num) must be of type int, string given
string(1) "1"
string(1) "0"
diff --git a/ext/standard/tests/math/decbin_basiclong_64bit.phpt b/ext/standard/tests/math/decbin_basiclong_64bit.phpt
index 1740af17031..bd824afacb3 100644
--- a/ext/standard/tests/math/decbin_basiclong_64bit.phpt
+++ b/ext/standard/tests/math/decbin_basiclong_64bit.phpt
@@ -15,17 +15,13 @@
$longVals = array(
MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
+ MAX_64Bit -1, MIN_64Bit + 1, MIN_64Bit - 1
);
foreach ($longVals as $longVal) {
echo "--- testing: $longVal ---\n";
- try {
- var_dump(decbin($longVal));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(decbin($longVal));
}
?>
@@ -54,8 +50,6 @@
string(32) "11111111111111111111111111111101"
--- testing: 9223372036854775806 ---
string(63) "111111111111111111111111111111111111111111111111111111111111110"
---- testing: 9.2233720368548E+18 ---
-TypeError: decbin(): Argument #1 ($num) must be of type int, float given
--- testing: -9223372036854775807 ---
string(64) "1000000000000000000000000000000000000000000000000000000000000001"
--- testing: -9.2233720368548E+18 ---
diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt
index 46b6e4af9fb..e34fdd68d25 100644
--- a/ext/standard/tests/math/decbin_variation1_64bit.phpt
+++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt
@@ -16,8 +16,6 @@
1,
12345,
-2345,
- 18446744073709551615, // largest decimal
- 18446744073709551616,
// float data
/* 7*/ 12.3456789000e10,
@@ -27,21 +25,13 @@
false,
TRUE,
FALSE,
-
- // empty data
-/*12*/ "",
- '',
];
// loop through each element of $inputs to check the behaviour of decbin()
foreach ($inputs as $i => $input) {
$iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- try {
- var_dump(decbin($input));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(decbin($input));
}
?>
@@ -61,28 +51,16 @@
string(64) "1111111111111111111111111111111111111111111111111111011011010111"
-- Iteration 5 --
-TypeError: decbin(): Argument #1 ($num) must be of type int, float given
+string(37) "1110010111110100110010001101000001000"
-- Iteration 6 --
-TypeError: decbin(): Argument #1 ($num) must be of type int, float given
+string(1) "1"
-- Iteration 7 --
-string(37) "1110010111110100110010001101000001000"
+string(1) "0"
-- Iteration 8 --
string(1) "1"
-- Iteration 9 --
string(1) "0"
-
--- Iteration 10 --
-string(1) "1"
-
--- Iteration 11 --
-string(1) "0"
-
--- Iteration 12 --
-TypeError: decbin(): Argument #1 ($num) must be of type int, string given
-
--- Iteration 13 --
-TypeError: decbin(): Argument #1 ($num) must be of type int, string given
diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt
index 61f3b6a8585..e39086dfd5c 100644
--- a/ext/standard/tests/math/dechex_basic.phpt
+++ b/ext/standard/tests/math/dechex_basic.phpt
@@ -11,17 +11,12 @@
"3950.5",
"3.9505e3",
"039",
- "0x5F",
true,
false,
);
foreach ($values as $value) {
- try {
- var_dump(dechex($value));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(dechex($value));
}
?>
@@ -43,6 +38,5 @@
Deprecated: Implicit conversion from float-string "3.9505e3" to int loses precision in %s on line %d
string(3) "f6e"
string(2) "27"
-TypeError: dechex(): Argument #1 ($num) must be of type int, string given
string(1) "1"
string(1) "0"
diff --git a/ext/standard/tests/math/dechex_basiclong_64bit.phpt b/ext/standard/tests/math/dechex_basiclong_64bit.phpt
index 19301f38546..210b6bae792 100644
--- a/ext/standard/tests/math/dechex_basiclong_64bit.phpt
+++ b/ext/standard/tests/math/dechex_basiclong_64bit.phpt
@@ -15,17 +15,13 @@
$longVals = array(
MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
+ MAX_64Bit -1, MIN_64Bit + 1, MIN_64Bit - 1
);
foreach ($longVals as $longVal) {
echo "--- testing: $longVal ---\n";
- try {
- var_dump(dechex($longVal));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(dechex($longVal));
}
?>
@@ -54,8 +50,6 @@
string(8) "fffffffd"
--- testing: 9223372036854775806 ---
string(16) "7ffffffffffffffe"
---- testing: 9.2233720368548E+18 ---
-TypeError: dechex(): Argument #1 ($num) must be of type int, float given
--- testing: -9223372036854775807 ---
string(16) "8000000000000001"
--- testing: -9.2233720368548E+18 ---
diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt
index 6f63d31dde5..24d36d0e15b 100644
--- a/ext/standard/tests/math/dechex_variation1_64bit.phpt
+++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt
@@ -16,8 +16,6 @@
1,
12345,
-2345,
- 18446744073709551615, // largest decimal
- 18446744073709551616,
// float data
/* 7*/ 12.3456789000e10,
@@ -27,21 +25,13 @@
false,
TRUE,
FALSE,
-
- // empty data
-/*12*/ "",
- '',
];
// loop through each element of $inputs to check the behaviour of dechex()
foreach ($inputs as $i => $input) {
$iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- try {
- var_dump(dechex($input));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(dechex($input));
}
?>
@@ -61,28 +51,16 @@
string(16) "fffffffffffff6d7"
-- Iteration 5 --
-TypeError: dechex(): Argument #1 ($num) must be of type int, float given
+string(10) "1cbe991a08"
-- Iteration 6 --
-TypeError: dechex(): Argument #1 ($num) must be of type int, float given
+string(1) "1"
-- Iteration 7 --
-string(10) "1cbe991a08"
+string(1) "0"
-- Iteration 8 --
string(1) "1"
-- Iteration 9 --
string(1) "0"
-
--- Iteration 10 --
-string(1) "1"
-
--- Iteration 11 --
-string(1) "0"
-
--- Iteration 12 --
-TypeError: dechex(): Argument #1 ($num) must be of type int, string given
-
--- Iteration 13 --
-TypeError: dechex(): Argument #1 ($num) must be of type int, string given
diff --git a/ext/standard/tests/strings/chr_error.phpt b/ext/standard/tests/strings/chr_error.phpt
deleted file mode 100644
index 1585acff87a..00000000000
--- a/ext/standard/tests/strings/chr_error.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Test chr() function : error conditions
---FILE--
-<?php
-
-echo "*** Testing chr() : error conditions ***\n";
-
-echo "\n-- Testing chr() function with no arguments --\n";
-try {
- var_dump( chr() );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-echo "\n-- Testing chr() function with more than expected no. of arguments --\n";
-$extra_arg = 10;
-try {
- var_dump( chr(72, $extra_arg) );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-?>
---EXPECT--
-*** Testing chr() : error conditions ***
-
--- Testing chr() function with no arguments --
-ArgumentCountError: chr() expects exactly 1 argument, 0 given
-
--- Testing chr() function with more than expected no. of arguments --
-ArgumentCountError: chr() expects exactly 1 argument, 2 given
diff --git a/ext/standard/tests/strings/crypt.phpt b/ext/standard/tests/strings/crypt.phpt
index 75e3a62adaf..06f3e941b9e 100644
--- a/ext/standard/tests/strings/crypt.phpt
+++ b/ext/standard/tests/strings/crypt.phpt
@@ -18,16 +18,9 @@
echo (CRYPT_MD5) ? ((crypt($str, $salt3) === $res_3) ? 'MD5' : 'MD5 - ERROR') : 'MD5', "\n";
echo (CRYPT_BLOWFISH) ? ((crypt($str, $salt4) === $res_4) ? 'BLO' : 'BLO - ERROR') : 'BLO', "\n";
-try {
- var_dump(crypt($str));
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
?>
--EXPECT--
STD
EXT
MD5
BLO
-ArgumentCountError: crypt() expects exactly 2 arguments, 1 given
diff --git a/ext/standard/tests/strings/fprintf_error.phpt b/ext/standard/tests/strings/fprintf_error.phpt
deleted file mode 100644
index 8cc0060bcf9..00000000000
--- a/ext/standard/tests/strings/fprintf_error.phpt
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-Test fprintf() function (errors)
---FILE--
-<?php
-
-/* Testing Error Conditions */
-echo "*** Testing Error Conditions ***\n";
-
-/* zero argument */
-try {
- var_dump( fprintf() );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-/* scalar argument */
-try {
- var_dump( fprintf(3) );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-/* NULL argument */
-try {
- var_dump( fprintf(NULL) );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-echo "Done\n";
-?>
---EXPECT--
-*** Testing Error Conditions ***
-ArgumentCountError: fprintf() expects at least 2 arguments, 0 given
-ArgumentCountError: fprintf() expects at least 2 arguments, 1 given
-ArgumentCountError: fprintf() expects at least 2 arguments, 1 given
-Done
diff --git a/ext/standard/tests/strings/str_replace_basic.phpt b/ext/standard/tests/strings/str_replace_basic.phpt
index 3139b594fad..98834c76e99 100644
--- a/ext/standard/tests/strings/str_replace_basic.phpt
+++ b/ext/standard/tests/strings/str_replace_basic.phpt
@@ -19,16 +19,6 @@
var_dump( str_replace("long string here", "", "", $count) );
var_dump( $count );
-$fp = fopen( __FILE__, "r" );
-$fp_copy = $fp;
-try {
- var_dump( str_replace($fp_copy, $fp_copy, $fp_copy, $fp_copy) );
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-var_dump( $fp_copy );
-fclose($fp);
-
?>
--EXPECTF--
*** Testing str_replace() on basic operations ***
@@ -40,5 +30,3 @@
int(1)
string(0) ""
int(0)
-TypeError: str_replace(): Argument #1 ($search) must be of type array|string, resource given
-resource(%d) of type (stream)
diff --git a/ext/standard/tests/strings/str_replace_variation3.phpt b/ext/standard/tests/strings/str_replace_variation3.phpt
index 71370f437d2..35c2a298218 100644
--- a/ext/standard/tests/strings/str_replace_variation3.phpt
+++ b/ext/standard/tests/strings/str_replace_variation3.phpt
@@ -93,21 +93,6 @@ function __toString() {
var_dump($count);
-echo "\n-- Testing Resources --\n";
-$resource1 = fopen( __FILE__, "r" );
-$resource2 = opendir( "." );
-try {
- var_dump(str_replace("stream", "FOUND", $resource1, $count));
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-try {
- var_dump(str_replace("stream", "FOUND", $resource2, $count));
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-
echo "\n-- Testing a longer and heredoc string --\n";
$string = <<<EOD
abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
@@ -144,9 +129,6 @@ function __toString() {
var_dump( str_replace("worldS", "FOUND", "{$str}S") );
-fclose($resource1);
-closedir($resource2);
-
?>
--EXPECTF--
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in %s on line %d
@@ -196,10 +178,6 @@ function __toString() {
}
int(1)
--- Testing Resources --
-TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, resource given
-TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, resource given
-
-- Testing a longer and heredoc string --
string(623) "FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
diff --git a/ext/standard/tests/strings/strip_tags_variation2.phpt b/ext/standard/tests/strings/strip_tags_variation2.phpt
index 2bf2de0ac82..009124c9cca 100644
--- a/ext/standard/tests/strings/strip_tags_variation2.phpt
+++ b/ext/standard/tests/strings/strip_tags_variation2.phpt
@@ -15,9 +15,6 @@
$unset_var = 10;
unset ($unset_var);
-//get a resource variable
-$fp = fopen(__FILE__, "r");
-
//get a class
class classA{
public function __toString(){
@@ -63,20 +60,13 @@ public function __toString(){
// unset data
@$unset_var,
-
- // resource variable
- $fp
);
// loop through each element of the array for allowable_tags
$iterator = 1;
foreach($values as $value) {
echo "-- Iteration $iterator --\n";
- try {
- var_dump(strip_tags($string, $value));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(strip_tags($string, $value));
$iterator++;
};
@@ -124,6 +114,4 @@ public function __toString(){
string(10) "helloworld"
-- Iteration 20 --
string(10) "helloworld"
--- Iteration 21 --
-TypeError: strip_tags(): Argument #2 ($allowed_tags) must be of type array|string|null, resource given
Done
diff --git a/ext/standard/tests/strings/stristr_variation2.phpt b/ext/standard/tests/strings/stristr_variation2.phpt
index d5c77a6c5d2..44a9e6a71ac 100644
--- a/ext/standard/tests/strings/stristr_variation2.phpt
+++ b/ext/standard/tests/strings/stristr_variation2.phpt
@@ -12,9 +12,6 @@ public function __toString() {
}
}
-//getting the resource
-$file_handle = fopen(__FILE__, "r");
-
// array with different values for $input
$inputs = array (
@@ -29,22 +26,12 @@ public function __toString() {
-20.5,
10.1234567e10,
- // array values
-/*8*/ array(),
- array(0),
- array(1, 2),
-
// boolean values
-/*11*/ true,
+/*8*/ true,
false,
- TRUE,
- FALSE,
// objects
-/*17*/ new sample(),
-
- // resource
-/*18*/ $file_handle,
+/*10*/ new sample(),
);
//defining '$pad_length' argument
@@ -54,16 +41,10 @@ public function __toString() {
$count = 1;
foreach($inputs as $input) {
echo "-- Iteration $count --\n";
- try {
- var_dump( stristr("Hello World", $input) );
- } catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
- }
+ var_dump( stristr("Hello World", $input) );
$count ++;
}
-fclose($file_handle); //closing the file handle
-
?>
--EXPECT--
*** Testing stristr() function: with unexpected inputs for 'needle' argument ***
@@ -82,20 +63,8 @@ public function __toString() {
-- Iteration 7 --
bool(false)
-- Iteration 8 --
-TypeError: stristr(): Argument #2 ($needle) must be of type string, array given
--- Iteration 9 --
-TypeError: stristr(): Argument #2 ($needle) must be of type string, array given
--- Iteration 10 --
-TypeError: stristr(): Argument #2 ($needle) must be of type string, array given
--- Iteration 11 --
-bool(false)
--- Iteration 12 --
-string(11) "Hello World"
--- Iteration 13 --
bool(false)
--- Iteration 14 --
+-- Iteration 9 --
string(11) "Hello World"
--- Iteration 15 --
+-- Iteration 10 --
bool(false)
--- Iteration 16 --
-TypeError: stristr(): Argument #2 ($needle) must be of type string, resource given
diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt
index c3dde30ae69..739d9d86721 100644
--- a/ext/standard/tests/strings/strpos.phpt
+++ b/ext/standard/tests/strings/strpos.phpt
@@ -67,12 +67,9 @@
echo "\n*** Testing strpos() with possible variations in offset ***\n";
$offset_values = array (
1, // offset = 1
- "string", // offset as string, converts to zero
- "", // offset as string, converts to zero
"0",
TRUE,
FALSE,
- "string12",
-10, // Not found
-15, // Found
-strlen($string),
@@ -81,11 +78,7 @@
/* loop through to get the "needle" position in $string */
for( $i = 0; $i < count( $offset_values ); $i++ ) {
echo "Position of 'Hello' with offset '$offset_values[$i]' is => ";
- try {
- var_dump( strpos($string, "Hello", $offset_values[$i]) );
- } catch (Throwable $e) {
- echo "\n", $e::class, ': ', $e->getMessage(), "\n";
- }
+ var_dump( strpos($string, "Hello", $offset_values[$i]) );
}
@@ -226,15 +219,9 @@ function __toString() {
*** Testing strpos() with possible variations in offset ***
Position of 'Hello' with offset '1' is => int(74)
-Position of 'Hello' with offset 'string' is =>
-TypeError: strpos(): Argument #3 ($offset) must be of type int, string given
-Position of 'Hello' with offset '' is =>
-TypeError: strpos(): Argument #3 ($offset) must be of type int, string given
Position of 'Hello' with offset '0' is => int(0)
Position of 'Hello' with offset '1' is => int(74)
Position of 'Hello' with offset '' is => int(0)
-Position of 'Hello' with offset 'string12' is =>
-TypeError: strpos(): Argument #3 ($offset) must be of type int, string given
Position of 'Hello' with offset '-10' is => bool(false)
Position of 'Hello' with offset '-15' is => int(74)
Position of 'Hello' with offset '-85' is => int(0)
diff --git a/ext/standard/tests/strings/strtr_variation6.phpt b/ext/standard/tests/strings/strtr_variation6.phpt
index a1597e24574..90ef75370eb 100644
--- a/ext/standard/tests/strings/strtr_variation6.phpt
+++ b/ext/standard/tests/strings/strtr_variation6.phpt
@@ -15,9 +15,6 @@ public function __toString() {
}
}
-//getting the resource
-$file_handle = fopen(__FILE__, "r");
-
//defining 'str' argument
$str = "012atm";
@@ -34,13 +31,8 @@ public function __toString() {
-20.5,
10.1234567e10,
- // array values
-/*7*/ array(),
- array(0),
- array(1, 2),
-
// boolean values
-/*10*/ true,
+/*7*/ true,
false,
TRUE,
FALSE,
@@ -50,10 +42,7 @@ public function __toString() {
null,
// objects
-/*16*/ new sample(),
-
- // resource
-/*17*/ $file_handle,
+/*13*/ new sample(),
);
//defining 'to' argument
@@ -64,15 +53,10 @@ public function __toString() {
for($index = 0; $index < count($from_arr); $index++) {
echo "-- Iteration $count --\n";
$from = $from_arr[$index];
- try {
- var_dump(strtr($str, $from, $to));
- } catch (Throwable $exception) {
- echo $exception::class, ': ', $exception->getMessage(), "\n";
- }
+ var_dump(strtr($str, $from, $to));
$count++;
}
-fclose($file_handle); //closing the file handle
?>
--EXPECTF--
*** Testing strtr() function: with unexpected inputs for 'from' ***
@@ -89,28 +73,20 @@ public function __toString() {
-- Iteration 6 --
string(6) "tm0atm"
-- Iteration 7 --
-TypeError: strtr(): Argument #2 ($from) must be of type string, array given
--- Iteration 8 --
-TypeError: strtr(): Argument #2 ($from) must be of type string, array given
--- Iteration 9 --
-TypeError: strtr(): Argument #2 ($from) must be of type string, array given
--- Iteration 10 --
string(6) "0a2atm"
--- Iteration 11 --
+-- Iteration 8 --
string(6) "012atm"
--- Iteration 12 --
+-- Iteration 9 --
string(6) "0a2atm"
--- Iteration 13 --
+-- Iteration 10 --
string(6) "012atm"
--- Iteration 14 --
+-- Iteration 11 --
Deprecated: strtr(): Passing null to parameter #2 ($from) of type array|string is deprecated in %s on line %d
string(6) "012atm"
--- Iteration 15 --
+-- Iteration 12 --
Deprecated: strtr(): Passing null to parameter #2 ($from) of type array|string is deprecated in %s on line %d
string(6) "012atm"
--- Iteration 16 --
+-- Iteration 13 --
string(6) "012ttm"
--- Iteration 17 --
-TypeError: strtr(): Argument #2 ($from) must be of type string, resource given
diff --git a/ext/standard/tests/strings/strtr_variation8.phpt b/ext/standard/tests/strings/strtr_variation8.phpt
index aee2fe6a356..290d44ad013 100644
--- a/ext/standard/tests/strings/strtr_variation8.phpt
+++ b/ext/standard/tests/strings/strtr_variation8.phpt
@@ -8,52 +8,16 @@
echo "*** Testing strtr() function: with unexpected inputs for 'replace_pairs' ***\n";
-//defining a class
-class sample {
- public function __toString() {
- return "sample object";
- }
-}
-
-//getting the resource
-$file_handle = fopen(__FILE__, "r");
-
//defining 'str' argument
$str = "012atm";
// array of inputs for 'replace_pairs' argument
$replace_pairs_arr = array (
- // integer values
- 0,
- 1,
- -2,
-
- // float values
- 10.5,
- -20.5,
- 10.5e10,
-
// array values
array(),
array(0),
array(1, 2),
-
- // boolean values
- true,
- false,
- TRUE,
- FALSE,
-
- // null values
- NULL,
- null,
-
- // objects
- new sample(),
-
- // resource
- $file_handle,
);
// loop through with each element of the $replace_pairs array to test strtr() function
@@ -61,70 +25,22 @@ public function __toString() {
for($index = 0; $index < count($replace_pairs_arr); $index++) {
echo "\n-- Iteration $count --\n";
$replace_pairs = $replace_pairs_arr[$index];
- try {
- var_dump(strtr($str, $replace_pairs));
- } catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
- }
+ var_dump(strtr($str, $replace_pairs));
$count ++;
}
-fclose($file_handle); //closing the file handle
-
echo "*** Done ***";
?>
--EXPECT--
*** Testing strtr() function: with unexpected inputs for 'replace_pairs' ***
-- Iteration 1 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, int given
-
--- Iteration 2 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, int given
-
--- Iteration 3 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, int given
-
--- Iteration 4 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, float given
-
--- Iteration 5 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, float given
-
--- Iteration 6 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, float given
-
--- Iteration 7 --
string(6) "012atm"
--- Iteration 8 --
+-- Iteration 2 --
string(6) "012atm"
--- Iteration 9 --
+-- Iteration 3 --
string(6) "122atm"
-
--- Iteration 10 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, true given
-
--- Iteration 11 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, false given
-
--- Iteration 12 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, true given
-
--- Iteration 13 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, false given
-
--- Iteration 14 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, null given
-
--- Iteration 15 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, null given
-
--- Iteration 16 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, sample given
-
--- Iteration 17 --
-TypeError: strtr(): Argument #2 ($from) must be of type array, resource given
*** Done ***