the whole shebang
This commit is contained in:
85
vendor/nikic/php-parser/test/code/parser/stmt/namespace/alias.test
vendored
Normal file
85
vendor/nikic/php-parser/test/code/parser/stmt/namespace/alias.test
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
Aliases (use)
|
||||
-----
|
||||
<?php
|
||||
|
||||
use A\B;
|
||||
use C\D as E;
|
||||
use F\G as H, J;
|
||||
|
||||
// evil alias notation - Do Not Use!
|
||||
use \A;
|
||||
use \A as B;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Use(
|
||||
uses: array(
|
||||
0: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
1: B
|
||||
)
|
||||
)
|
||||
alias: B
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Use(
|
||||
uses: array(
|
||||
0: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: C
|
||||
1: D
|
||||
)
|
||||
)
|
||||
alias: E
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_Use(
|
||||
uses: array(
|
||||
0: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: F
|
||||
1: G
|
||||
)
|
||||
)
|
||||
alias: H
|
||||
)
|
||||
1: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: J
|
||||
)
|
||||
)
|
||||
alias: J
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_Use(
|
||||
uses: array(
|
||||
0: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
alias: A
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_Use(
|
||||
uses: array(
|
||||
0: Stmt_UseUse(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
alias: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
42
vendor/nikic/php-parser/test/code/parser/stmt/namespace/braced.test
vendored
Normal file
42
vendor/nikic/php-parser/test/code/parser/stmt/namespace/braced.test
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
Braced namespaces
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Foo\Bar {
|
||||
foo;
|
||||
}
|
||||
namespace {
|
||||
bar;
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
1: Bar
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Namespace(
|
||||
name: null
|
||||
stmts: array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
13
vendor/nikic/php-parser/test/code/parser/stmt/namespace/mix.test-fail
vendored
Normal file
13
vendor/nikic/php-parser/test/code/parser/stmt/namespace/mix.test-fail
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Namespace types cannot be mixed
|
||||
-----
|
||||
<?php
|
||||
namespace A;
|
||||
namespace B {}
|
||||
-----
|
||||
Cannot mix bracketed namespace declarations with unbracketed namespace declarations on line 3
|
||||
-----
|
||||
<?php
|
||||
namespace A {}
|
||||
namespace B;
|
||||
-----
|
||||
Cannot mix bracketed namespace declarations with unbracketed namespace declarations on line 3
|
42
vendor/nikic/php-parser/test/code/parser/stmt/namespace/name.test
vendored
Normal file
42
vendor/nikic/php-parser/test/code/parser/stmt/namespace/name.test
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
Different name types
|
||||
-----
|
||||
<?php
|
||||
|
||||
A;
|
||||
A\B;
|
||||
\A\B;
|
||||
namespace\A\B;
|
||||
-----
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
1: B
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_ConstFetch(
|
||||
name: Name_FullyQualified(
|
||||
parts: array(
|
||||
0: A
|
||||
1: B
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Expr_ConstFetch(
|
||||
name: Name_Relative(
|
||||
parts: array(
|
||||
0: A
|
||||
1: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
25
vendor/nikic/php-parser/test/code/parser/stmt/namespace/name.test-fail
vendored
Normal file
25
vendor/nikic/php-parser/test/code/parser/stmt/namespace/name.test-fail
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Invalid namespace names
|
||||
-----
|
||||
<?php namespace self;
|
||||
-----
|
||||
Cannot use "self" as namespace name as it is reserved on line 1
|
||||
-----
|
||||
<?php namespace parent;
|
||||
-----
|
||||
Cannot use "parent" as namespace name as it is reserved on line 1
|
||||
-----
|
||||
<?php namespace static;
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NS_SEPARATOR or '{' on line 1
|
||||
-----
|
||||
<?php use A as self;
|
||||
-----
|
||||
Cannot use "A" as "self" because "self" is a special class name on line 1
|
||||
-----
|
||||
<?php use B as parent;
|
||||
-----
|
||||
Cannot use "B" as "parent" because "parent" is a special class name on line 1
|
||||
-----
|
||||
<?php use C as static;
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1
|
10
vendor/nikic/php-parser/test/code/parser/stmt/namespace/nested.test-fail
vendored
Normal file
10
vendor/nikic/php-parser/test/code/parser/stmt/namespace/nested.test-fail
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Nested namespaces are not allowed
|
||||
-----
|
||||
<?php
|
||||
namespace A {
|
||||
namespace B {
|
||||
|
||||
}
|
||||
}
|
||||
-----
|
||||
Namespace declarations cannot be nested on line 3
|
45
vendor/nikic/php-parser/test/code/parser/stmt/namespace/notBraced.test
vendored
Normal file
45
vendor/nikic/php-parser/test/code/parser/stmt/namespace/notBraced.test
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
Semicolon style namespaces
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Foo\Bar;
|
||||
foo;
|
||||
|
||||
namespace Bar;
|
||||
bar;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
1: Bar
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Bar
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
37
vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test
vendored
Normal file
37
vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
Some statements may occur outside of namespaces
|
||||
-----
|
||||
<?php
|
||||
declare(A='B');
|
||||
namespace B {
|
||||
|
||||
}
|
||||
__halt_compiler()
|
||||
?>
|
||||
Hi!
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Declare(
|
||||
declares: array(
|
||||
0: Stmt_DeclareDeclare(
|
||||
key: A
|
||||
value: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_HaltCompiler(
|
||||
remaining: Hi!
|
||||
)
|
||||
)
|
13
vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test-fail
vendored
Normal file
13
vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test-fail
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
There (mostly) can't be statements outside of namespaces
|
||||
-----
|
||||
<?php
|
||||
echo 1;
|
||||
namespace A;
|
||||
-----
|
||||
Namespace declaration statement has to be the very first statement in the script on line 3
|
||||
-----
|
||||
<?php
|
||||
namespace A {}
|
||||
echo 1;
|
||||
-----
|
||||
No code may exist outside of namespace {} on line 3
|
Reference in New Issue
Block a user