php-src/ext/spl/tests/fixedarray_005.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

29 lines
695 B
PHP

--TEST--
SPL: FixedArray: Invalid arguments
--FILE--
<?php
try {
$a = new SplFixedArray(new stdClass);
} catch (TypeError $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
try {
$a = new SplFixedArray('FOO');
} catch (TypeError $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
try {
$a = new SplFixedArray('');
} catch (TypeError $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECT--
Ok - SplFixedArray::__construct(): Argument #1 ($size) must be of type int, stdClass given
Ok - SplFixedArray::__construct(): Argument #1 ($size) must be of type int, string given
Ok - SplFixedArray::__construct(): Argument #1 ($size) must be of type int, string given