diff --git a/CHANGELOG.md b/CHANGELOG.md index 9870a95..649efd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) -------------------------- diff --git a/lib/PhpParser/ParserAbstract.php b/lib/PhpParser/ParserAbstract.php index 0e4fc82..87c3ee8 100644 --- a/lib/PhpParser/ParserAbstract.php +++ b/lib/PhpParser/ParserAbstract.php @@ -470,6 +470,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())); diff --git a/test/code/parser/stmt/namespace/commentAfterNamespace.test b/test/code/parser/stmt/namespace/commentAfterNamespace.test new file mode 100644 index 0000000..3f379b7 --- /dev/null +++ b/test/code/parser/stmt/namespace/commentAfterNamespace.test @@ -0,0 +1,22 @@ +Trailing comment after braced namespace declaration +----- +