mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Allow nop statements before namespace declaration
This commit is contained in:
parent
f8a40b3f24
commit
4c7ad7e194
@ -463,8 +463,10 @@ abstract class ParserAbstract implements Parser
|
||||
continue;
|
||||
}
|
||||
|
||||
/* declare() and __halt_compiler() can be used before a namespace declaration */
|
||||
if ($stmt instanceof Node\Stmt\Declare_ || $stmt instanceof Node\Stmt\HaltCompiler) {
|
||||
/* declare(), __halt_compiler() and nops can be used before a namespace declaration */
|
||||
if ($stmt instanceof Node\Stmt\Declare_
|
||||
|| $stmt instanceof Node\Stmt\HaltCompiler
|
||||
|| $stmt instanceof Node\Stmt\Nop) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
// parse sections
|
||||
$parts = explode("\n-----\n", $fileContents);
|
||||
$parts = preg_split("/\n-----(?:\n|$)/", $fileContents);
|
||||
|
||||
// first part is the name
|
||||
$name = array_shift($parts) . ' (' . $fileName . ')';
|
||||
|
@ -33,4 +33,26 @@ array(
|
||||
2: Stmt_HaltCompiler(
|
||||
remaining: Hi!
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
/* Comment */
|
||||
;
|
||||
namespace Foo;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Nop(
|
||||
comments: array(
|
||||
0: /* Comment */
|
||||
)
|
||||
)
|
||||
1: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user