php-src/Zend/tests/ns_071.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

26 lines
499 B
PHP

--TEST--
Testing parameter type-hinted (array) with default value inside namespace
--FILE--
<?php
namespace foo;
class bar {
public function __construct(array $x = NULL) {
var_dump($x);
}
}
new bar(null);
new bar(new \stdclass);
?>
--EXPECTF--
NULL
Fatal error: Uncaught TypeError: foo\bar::__construct(): Argument #1 ($x) must be of type ?array, stdClass given, called in %s:%d
Stack trace:
#0 %s(%d): foo\bar->__construct(Object(stdClass))
#1 {main}
thrown in %s on line %d