xref: /PHP-8.3/Zend/tests/bug42802.phpt (revision 7aacc705)
1--TEST--
2Bug #42802 (Namespace not supported in types)
3--FILE--
4<?php
5namespace foo;
6
7class bar {
8}
9
10function test1(bar $bar) {
11    echo "ok\n";
12}
13
14function test2(\foo\bar $bar) {
15        echo "ok\n";
16}
17function test3(\foo\bar $bar) {
18        echo "ok\n";
19}
20function test4(\Exception $e) {
21    echo "ok\n";
22}
23function test5(\bar $bar) {
24        echo "bug\n";
25}
26
27$x = new bar();
28$y = new \Exception();
29test1($x);
30test2($x);
31test3($x);
32test4($y);
33test5($x);
34?>
35--EXPECTF--
36ok
37ok
38ok
39ok
40
41Fatal error: Uncaught TypeError: foo\test5(): Argument #1 ($bar) must be of type bar, foo\bar given, called in %s:%d
42Stack trace:
43#0 %s(%d): foo\test5(Object(foo\bar))
44#1 {main}
45  thrown in %sbug42802.php on line %d
46