php-src/Zend/tests/ns_072.phpt

38 lines
596 B
Plaintext
Raw Normal View History

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
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
Stack trace:
#0 %s(%d): foo\bar->__construct()
#1 {main}
thrown in %s on line %d