1--TEST-- 2Testing parameter type-hinted with interface 3--FILE-- 4<?php 5 6namespace foo; 7 8interface foo { 9 10} 11 12class bar { 13 public function __construct(foo $x = NULL) { 14 var_dump($x); 15 } 16} 17 18class test implements foo { 19 20} 21 22 23new bar(new test); 24new bar(null); 25new bar(new \stdclass); 26 27?> 28--EXPECTF-- 29object(foo\test)#%d (0) { 30} 31NULL 32 33Fatal error: Uncaught TypeError: foo\bar::__construct(): Argument #1 ($x) must be of type ?foo\foo, stdClass given, called in %s:%d 34Stack trace: 35#0 %s(%d): foo\bar->__construct(Object(stdClass)) 36#1 {main} 37 thrown in %s on line %d 38