Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ $power = 20; // Chosen to be well within a memory_limit
$arr = range(0, 2**$power);
try {
array_merge(...array_fill(0, 2**(32-$power), $arr));
} catch (Error $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECTF--
The total number of elements must be lower than %d
Error: The total number of elements must be lower than %d
12 changes: 6 additions & 6 deletions ext/standard/tests/array/array_chunk2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ $input_array = array('a', 'b', 'c', 'd', 'e');

try {
var_dump(array_chunk($input_array, 0));
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
var_dump(array_chunk($input_array, 0, true));
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump(array_chunk($input_array, 1));
Expand All @@ -24,8 +24,8 @@ var_dump(array_chunk($input_array, 10));
var_dump(array_chunk($input_array, 10, true));
?>
--EXPECT--
array_chunk(): Argument #2 ($length) must be greater than 0
array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
array(5) {
[0]=>
array(1) {
Expand Down
24 changes: 12 additions & 12 deletions ext/standard/tests/array/array_chunk_variation5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ foreach ($sizes as $size){
echo "\n-- Testing array_chunk() when size = $size --\n";
try {
var_dump( array_chunk($input_array, $size) );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump( array_chunk($input_array, $size, true) );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump( array_chunk($input_array, $size, false) );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
?>
--EXPECT--
*** Testing array_chunk() : usage variations ***

-- Testing array_chunk() when size = -1 --
array_chunk(): Argument #2 ($length) must be greater than 0
array_chunk(): Argument #2 ($length) must be greater than 0
array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0

-- Testing array_chunk() when size = 4 --
array(1) {
Expand Down Expand Up @@ -82,9 +82,9 @@ array(1) {
}

-- Testing array_chunk() when size = 0 --
array_chunk(): Argument #2 ($length) must be greater than 0
array_chunk(): Argument #2 ($length) must be greater than 0
array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0

-- Testing array_chunk() when size = 1 --
array(3) {
Expand Down
22 changes: 11 additions & 11 deletions ext/standard/tests/array/array_combine_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ var_dump( array_combine(array(), array()) );
echo "\n-- Testing array_combine() function with empty array for \$keys argument --\n";
try {
var_dump( array_combine(array(), array(1, 2)) );
} catch (\ValueError $e) {
echo $e->getMessage();
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

// Testing array_combine by passing empty array to $values
echo "\n-- Testing array_combine() function with empty array for \$values argument --\n";
echo "-- Testing array_combine() function with empty array for \$values argument --\n";
try {
var_dump( array_combine(array(1, 2), array()) );
} catch (\ValueError $e) {
echo $e->getMessage();
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

// Testing array_combine with arrays having unequal number of elements
echo "\n-- Testing array_combine() function by passing array with unequal number of elements --\n";
echo "-- Testing array_combine() function by passing array with unequal number of elements --\n";
try {
var_dump( array_combine(array(1, 2), array(1, 2, 3)) );
} catch (\ValueError $e) {
echo $e->getMessage();
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
Expand All @@ -41,8 +41,8 @@ array(0) {
}

-- Testing array_combine() function with empty array for $keys argument --
array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
-- Testing array_combine() function with empty array for $values argument --
array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
-- Testing array_combine() function by passing array with unequal number of elements --
array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ array_diff() memory leak with custom type checks

try {
array_diff([123], 'x');
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
array_diff(): Argument #2 must be of type array, string given
TypeError: array_diff(): Argument #2 must be of type array, string given
6 changes: 3 additions & 3 deletions ext/standard/tests/array/array_diff_max_elements.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ $power = 20; // Chosen to be well within a memory_limit
$arr = range(0, 2**$power);
try {
array_diff(...array_fill(0, 2**(32-$power), $arr));
} catch (Error $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECTF--
The total number of elements must be lower than %d
Error: The total number of elements must be lower than %d
6 changes: 3 additions & 3 deletions ext/standard/tests/array/array_fill_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ $val = 1;

try {
var_dump( array_fill($start_key,$num,$val) );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
*** Testing array_fill() : error conditions ***
array_fill(): Argument #2 ($count) must be greater than or equal to 0
ValueError: array_fill(): Argument #2 ($count) must be greater than or equal to 0
6 changes: 3 additions & 3 deletions ext/standard/tests/array/array_fill_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ $intMax = 2147483647;
// calling array_fill() with 'count' larger than INT_MAX
try {
$array = array_fill(0, $intMax+1, 1);
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

// calling array_fill() with 'count' equals to INT_MAX
$array = array_fill(0, $intMax, 1);

?>
--EXPECTF--
array_fill(): Argument #2 ($count) is too large
ValueError: array_fill(): Argument #2 ($count) is too large

Fatal error: Possible integer overflow in memory allocation (%d * %d + %d) in %s on line %d
6 changes: 3 additions & 3 deletions ext/standard/tests/array/array_fill_variation6.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ var_dump(
);
try {
$a[] = "bar";
} catch (Error $ex) {
echo $ex->getMessage(), PHP_EOL;
} catch (Throwable $ex) {
echo $ex::class, ': ', $ex->getMessage(), "\n";
}
?>
--EXPECT--
int(1)
bool(true)
Cannot add element to the array as the next element is already occupied
Error: Cannot add element to the array as the next element is already occupied
2 changes: 1 addition & 1 deletion ext/standard/tests/array/array_filter_invalid_mode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Test array_filter() function : usage variations - mode exception
try {
var_dump(array_filter([], mode: 999));
} catch (Throwable $e) {
echo $e::class . ': '.$e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done"
Expand Down
10 changes: 5 additions & 5 deletions ext/standard/tests/array/array_filter_variation10.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ echo "*** Testing array_filter() : usage variations - 'callback' expecting secon
try {
var_dump( array_filter($small, 'dump', false) );
} catch (Throwable $e) {
echo "Exception: " . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "*** Testing array_filter() with various use types ***\n";
Expand All @@ -45,8 +45,8 @@ var_dump(array_filter($mixed, 'is_numeric', 0));

try {
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_BOTH));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done"
Expand All @@ -73,7 +73,7 @@ array(3) {
NULL
}
*** Testing array_filter() : usage variations - 'callback' expecting second argument ***
Exception: Too few arguments to function dump(), 1 passed and exactly 2 expected
ArgumentCountError: Too few arguments to function dump(), 1 passed and exactly 2 expected
*** Testing array_filter() with various use types ***
array(2) {
[1]=>
Expand All @@ -87,5 +87,5 @@ array(2) {
["b"]=>
int(2)
}
is_numeric() expects exactly 1 argument, 2 given
ArgumentCountError: is_numeric() expects exactly 1 argument, 2 given
Done
12 changes: 6 additions & 6 deletions ext/standard/tests/array/array_filter_variation9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ var_dump( array_filter($input, 'chr') );
// using language construct 'echo' as 'callback'
try {
var_dump( array_filter($input, 'echo') );
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

// using language construct 'isset' as 'callback'
try {
var_dump( array_filter($input, 'isset') );
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done"
Expand All @@ -54,6 +54,6 @@ array(4) {
[3]=>
int(100)
}
array_filter(): Argument #2 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
array_filter(): Argument #2 ($callback) must be a valid callback or null, function "isset" not found or invalid function name
TypeError: array_filter(): Argument #2 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
TypeError: array_filter(): Argument #2 ($callback) must be a valid callback or null, function "isset" not found or invalid function name
Done
12 changes: 6 additions & 6 deletions ext/standard/tests/array/array_key_exists.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ echo "\n*** Testing error conditions ***\n";
// first args as array
try {
array_key_exists(array(), array());
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
} catch (Throwable $exception) {
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

echo "\n*** Testing operation on objects ***\n";
Expand All @@ -76,8 +76,8 @@ class key_check
$key_check_obj = new key_check; //new object
try {
var_dump(array_key_exists("public_var", $key_check_obj));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done\n";
Expand Down Expand Up @@ -250,8 +250,8 @@ bool(false)
bool(true)

*** Testing error conditions ***
Cannot access offset of type array on array
TypeError: Cannot access offset of type array on array

*** Testing operation on objects ***
array_key_exists(): Argument #2 ($array) must be of type array, key_check given
TypeError: array_key_exists(): Argument #2 ($array) must be of type array, key_check given
Done
8 changes: 4 additions & 4 deletions ext/standard/tests/array/array_key_exists_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
try {
var_dump( array_key_exists($input, $search) );
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
} catch (Throwable $exception) {
echo $exception::class, ': ', $exception->getMessage(), "\n";
}
$iterator++;
};
Expand Down Expand Up @@ -133,7 +133,7 @@ bool(false)
bool(false)

-- Iteration 13 --
Cannot access offset of type array on array
TypeError: Cannot access offset of type array on array

-- Iteration 14 --
bool(true)
Expand All @@ -145,7 +145,7 @@ bool(true)
bool(true)

-- Iteration 17 --
Cannot access offset of type classA on array
TypeError: Cannot access offset of type classA on array

-- Iteration 18 --

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/array/array_key_exists_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ foreach($keys as $key) {
echo "Pass float as \$key:\n";
try {
var_dump(array_key_exists($key, $search));
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
} catch (Throwable $exception) {
echo $exception::class, ': ', $exception->getMessage(), "\n";
}
echo "Cast float to int:\n";
var_dump(array_key_exists((int)$key, $search));
Expand Down
8 changes: 4 additions & 4 deletions ext/standard/tests/array/array_map_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function callback1() {
try {
var_dump( array_map('callback1') );
} catch (Throwable $e) {
echo "Exception: " . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\n-- Testing array_map() function with less no. of arrays than callback function arguments --\n";
Expand All @@ -23,7 +23,7 @@ function callback2($p, $q) {
try {
var_dump( array_map('callback2', $arr1) );
} catch (Throwable $e) {
echo "Exception: " . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\n-- Testing array_map() function with more no. of arrays than callback function arguments --\n";
Expand All @@ -37,10 +37,10 @@ echo "Done";
*** Testing array_map() : error conditions ***

-- Testing array_map() function with one less than expected no. of arguments --
Exception: array_map() expects at least 2 arguments, 1 given
ArgumentCountError: array_map() expects at least 2 arguments, 1 given

-- Testing array_map() function with less no. of arrays than callback function arguments --
Exception: Too few arguments to function callback2(), 1 passed and exactly 2 expected
ArgumentCountError: Too few arguments to function callback2(), 1 passed and exactly 2 expected

-- Testing array_map() function with more no. of arrays than callback function arguments --
array(2) {
Expand Down
Loading
Loading