--TEST-- Union of null and intersection type --FILE-- foo1($a); $test->foo2($a); $test->foo1($n); $test->foo2($n); $test->prop1 = $a; $test->prop1 = $n; $test->prop2 = $a; $test->prop2 = $n; $c = new C(); try { $test->foo1($c); } catch (\TypeError $e) { echo $e->getMessage(), \PHP_EOL; } try { $test->foo2($c); } catch (\TypeError $e) { echo $e->getMessage(), \PHP_EOL; } try { $test->prop1 = $c; } catch (\TypeError $e) { echo $e->getMessage(), \PHP_EOL; } try { $test->prop2 = $c; } catch (\TypeError $e) { echo $e->getMessage(), \PHP_EOL; } ?> ===DONE=== --EXPECTF-- object(A)#2 (0) { } object(A)#2 (0) { } NULL NULL Test::foo1(): Argument #1 ($v) must be of type (X&Y)|null, C given, called in %s on line %d Test::foo2(): Argument #1 ($v) must be of type (X&Y)|null, C given, called in %s on line %d Cannot assign C to property Test::$prop1 of type (X&Y)|null Cannot assign C to property Test::$prop2 of type (X&Y)|null ===DONE===