1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Handle Nop statement after brace-style namespace

Fixes #412.
This commit is contained in:
Nikita Popov 2017-08-29 23:14:27 +02:00
parent 4d4896e553
commit a10780ca0d
3 changed files with 26 additions and 1 deletions

View File

@ -1,7 +1,9 @@
Version 3.1.1-dev
-----------------
Nothing yet.
### Fixed
* Fixed syntax error on comment after brace-style namespace declaration. (#412)
Version 3.1.0 (2017-07-28)
--------------------------

View File

@ -445,6 +445,7 @@ abstract class ParserAbstract implements Parser
if ($stmt instanceof Node\Stmt\Namespace_) {
$afterFirstNamespace = true;
} elseif (!$stmt instanceof Node\Stmt\HaltCompiler
&& !$stmt instanceof Node\Stmt\Nop
&& $afterFirstNamespace && !$hasErrored) {
$this->emitError(new Error(
'No code may exist outside of namespace {}', $stmt->getAttributes()));

View File

@ -0,0 +1,22 @@
Trailing comment after braced namespace declaration
-----
<?php
namespace Foo {}
// Comment
-----
array(
0: Stmt_Namespace(
name: Name(
parts: array(
0: Foo
)
)
stmts: array(
)
)
1: Stmt_Nop(
comments: array(
0: // Comment
)
)
)