1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-11 17:09:41 +01:00
PHP-Parser/test/code/parser/stmt/namespace/outsideStmtInvalid.test
Nikita Popov a6846e3b71 Always use Identifier nodes
The parser will now always generate Identifier nodes (for
non-namespaced identifiers). This obsoletes the useIdentifierNodes
parser option.

Node constructors still accepts strings and will implicitly create
an Identifier wrapper. Identifier implement __toString(), so that
outside of strict-mode many things continue to work without changes.
2017-04-28 20:57:32 +02:00

109 lines
1.9 KiB
Plaintext

There (mostly) can't be statements outside of namespaces
-----
<?php
echo 1;
echo 2;
namespace A;
-----
Namespace declaration statement has to be the very first statement in the script on line 4
array(
0: Stmt_Echo(
exprs: array(
0: Scalar_LNumber(
value: 1
)
)
)
1: Stmt_Echo(
exprs: array(
0: Scalar_LNumber(
value: 2
)
)
)
2: Stmt_Namespace(
name: Name(
parts: array(
0: A
)
)
stmts: array(
)
)
)
-----
<?php
namespace A {}
echo 1;
-----
No code may exist outside of namespace {} from 3:1 to 3:7
array(
0: Stmt_Namespace(
name: Name(
parts: array(
0: A
)
)
stmts: array(
)
)
1: Stmt_Echo(
exprs: array(
0: Scalar_LNumber(
value: 1
)
)
)
)
-----
<?php
namespace A {}
declare(ticks=1);
foo();
namespace B {}
-----
No code may exist outside of namespace {} from 3:1 to 3:17
array(
0: Stmt_Namespace(
name: Name(
parts: array(
0: A
)
)
stmts: array(
)
)
1: Stmt_Declare(
declares: array(
0: Stmt_DeclareDeclare(
key: Identifier(
name: ticks
)
value: Scalar_LNumber(
value: 1
)
)
)
stmts: null
)
2: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: foo
)
)
args: array(
)
)
)
3: Stmt_Namespace(
name: Name(
parts: array(
0: B
)
)
stmts: array(
)
)
)