xref: /php-src/Zend/tests/namespaces/ns_092.phpt (revision 275f63e7)
1--TEST--
2Typed group use statements
3--FILE--
4<?php
5namespace Foo\Bar {
6    class A { function __construct() {echo __METHOD__,"\n";} }
7    class B { function __construct() {echo __METHOD__,"\n";} }
8    function fiz(){ echo __FUNCTION__,"\n"; }
9    function biz(){ echo __FUNCTION__,"\n"; }
10    function buz(){ echo __FUNCTION__,"\n"; }
11    const FOO = 1;
12    const BAR = 2;
13}
14namespace Fiz\Biz\Buz {
15
16    use function Foo\Bar\{
17        fiz,
18        biz,
19        buz as boz,
20        A // <- this one must fail
21    };
22
23    use const Foo\Bar\{
24        FOO as FOZ,
25        BAR,
26        B // <- this one must fail
27    };
28
29    use Foo\Bar\{ A, B, const BAR as BOZ };
30
31    function buz(){ echo __FUNCTION__,"\n"; }
32    const FOO = 100;
33
34    echo "==== MIXED ====\n";
35    new A();
36    new B();
37    var_dump(BOZ);
38    echo "===== CONSTANTS ====\n";
39    var_dump(FOO);
40    var_dump(FOZ);
41    var_dump(BAR);
42    var_dump(defined('B'));
43    echo "===== FUNCTIONS ====\n";
44    buz();
45    fiz();
46    biz();
47    boz();
48    A();
49}
50?>
51--EXPECTF--
52==== MIXED ====
53Foo\Bar\A::__construct
54Foo\Bar\B::__construct
55int(2)
56===== CONSTANTS ====
57int(100)
58int(1)
59int(2)
60bool(false)
61===== FUNCTIONS ====
62Fiz\Biz\Buz\buz
63Foo\Bar\fiz
64Foo\Bar\biz
65Foo\Bar\buz
66
67Fatal error: Uncaught Error: Call to undefined function Foo\Bar\A() in %sns_092.php:45
68Stack trace:
69#0 {main}
70  thrown in %sns_092.php on line 45
71