2008-11-10 11:39:35 +00:00
--TEST--
Testing parameter type-hinted with interface
--FILE--
<?php
namespace foo;
interface foo {
}
class bar {
public function __construct(foo $x = NULL) {
var_dump($x);
}
}
class test implements foo {
}
new bar(new test);
new bar(null);
2008-12-04 20:12:30 +00:00
new bar(new \stdclass);
2008-11-10 11:39:35 +00:00
?>
--EXPECTF--
2008-11-10 15:07:09 +00:00
object(foo\test)#%d (0) {
2008-11-10 11:39:35 +00:00
}
NULL
2015-05-17 22:31:43 +00:00
Fatal error: Uncaught TypeError: Argument 1 passed to foo\bar::__construct() must implement interface foo\foo, instance of stdClass given, called in %s on line %d and defined in %s:%d
2015-05-17 16:59:34 +00:00
Stack trace:
#0 %s(%d): foo\bar->__construct()
#1 {main}
thrown in %s on line %d