1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 00:32:23 +01:00
Files
archived-php-src/ext/standard/tests/array/max.phpt
Máté Kocsis fbe30592d6 Improve type error messages when an object is given
From now on, we always display the given object's type instead of just reporting "object".
Additionally, make the format of return type errors match the format of argument errors.

Closes GH-5625
2020-05-26 19:06:19 +02:00

46 lines
844 B
PHP

--TEST--
max() tests
--INI--
precision=14
--FILE--
<?php
try {
var_dump(max(1));
} catch (\TypeError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(max(array()));
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(max(new stdclass));
} catch (\TypeError $e) {
echo $e->getMessage() . "\n";
}
var_dump(max(2,1,2));
var_dump(max(2.1,2.11,2.09));
var_dump(max("", "t", "b"));
var_dump(max(false, true, false));
var_dump(max(true, false, true));
var_dump(max(1, true, false, true));
var_dump(max(0, true, false, true));
?>
--EXPECT--
max(): Argument #1 ($arg) must be of type array, int given
max(): Argument #1 ($arg) must contain at least one element
max(): Argument #1 ($arg) must be of type array, stdClass given
int(2)
float(2.11)
string(1) "t"
bool(true)
bool(true)
int(1)
bool(true)