xref: /php-src/Zend/tests/namespaces/ns_058.phpt (revision 275f63e7)
1--TEST--
2058: Usage of 'namespace' in compound names (out of namespace)
3--FILE--
4<?php
5const C = "const ok\n";
6
7function foo() {
8    return "func ok\n";
9}
10
11class foo {
12    const C = "const ok\n";
13    const C2 = namespace\C;
14    static $var = "var ok\n";
15    function __construct() {
16        echo "class ok\n";
17    }
18    static function bar() {
19        return "method ok\n";
20    }
21}
22
23function f1($x=namespace\C) {
24    return $x;
25}
26function f2($x=namespace\foo::C) {
27    return $x;
28}
29
30function f3(namespace\foo $x) {
31    return "ok\n";
32}
33
34echo namespace\C;
35echo namespace\foo();
36echo namespace\foo::C;
37echo namespace\foo::C2;
38echo namespace\foo::$var;
39echo namespace\foo::bar();
40echo namespace\f1();
41echo namespace\f2();
42echo namespace\f3(new namespace\foo());
43echo namespace\unknown;
44?>
45--EXPECTF--
46const ok
47func ok
48const ok
49const ok
50var ok
51method ok
52const ok
53const ok
54class ok
55ok
56
57Fatal error: Uncaught Error: Undefined constant "unknown" in %s:%d
58Stack trace:
59#0 {main}
60  thrown in %sns_058.php on line %d
61