diff vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmtInvalid.test @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 5fb285c0d0e3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmtInvalid.test	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,105 @@
+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: ticks
+                value: Scalar_LNumber(
+                    value: 1
+                )
+            )
+        )
+        stmts: null
+    )
+    2: Expr_FuncCall(
+        name: Name(
+            parts: array(
+                0: foo
+            )
+        )
+        args: array(
+        )
+    )
+    3: Stmt_Namespace(
+        name: Name(
+            parts: array(
+                0: B
+            )
+        )
+        stmts: array(
+        )
+    )
+)
\ No newline at end of file