php-src/Zend/tests/add_002.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
465 B
PHP

--TEST--
adding objects to arrays
--FILE--
<?php
$a = array(1,2,3);
$o = new stdclass;
$o->prop = "value";
try {
var_dump($a + $o);
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
}
$c = $a + $o;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
Exception: Unsupported operand types: array + stdClass
Fatal error: Uncaught TypeError: Unsupported operand types: array + stdClass in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d