Recognize halt_compiler() ?> (without ;)

This commit is contained in:
nikic 2011-10-18 18:03:28 +02:00
parent afdfb6bf08
commit 69b298c4b5
2 changed files with 2 additions and 1 deletions

View File

@ -117,7 +117,7 @@ class PHPParser_Lexer
// ensure that it is followed by ();
// this simplifies the situation, by not allowing any comments
// in between of the tokens.
if (!preg_match('~\s*\(\s*\)\s*;~', $textAfter, $matches)) {
if (!preg_match('~\s*\(\s*\)\s*(?:;|\?>)~', $textAfter, $matches)) {
throw new PHPParser_Error('__halt_compiler must be followed by "();"');
}

View File

@ -87,6 +87,7 @@ class PHPParser_Tests_LexerTest extends PHPUnit_Framework_TestCase
return array(
array('<?php ... __halt_compiler();Remaining Text', 'Remaining Text'),
array('<?php ... __halt_compiler ( ) ;Remaining Text', 'Remaining Text'),
array('<?php ... __halt_compiler() ?>Remaining Text', 'Remaining Text'),
//array('<?php ... __halt_compiler();' . "\0", "\0"),
//array('<?php ... __halt_compiler /* */ ( ) ;Remaining Text', 'Remaining Text'),
);