ns_072.phpt 511 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Testing parameter type-hinted with interface
  3. --FILE--
  4. <?php
  5. namespace foo;
  6. interface foo {
  7. }
  8. class bar {
  9. public function __construct(foo $x = NULL) {
  10. var_dump($x);
  11. }
  12. }
  13. class test implements foo {
  14. }
  15. new bar(new test);
  16. new bar(null);
  17. new bar(new \stdclass);
  18. ?>
  19. --EXPECTF--
  20. object(foo\test)#%d (0) {
  21. }
  22. NULL
  23. Catchable fatal error: 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 on line %d