fix(compiler): 修复命名空间尾部有注释导致编译不通过

pull/29/head
Yurun 1 month ago
parent 2287695b44
commit a3d8f57ef4
  1. 2
      src/Preprocessor.php
  2. 2
      src/Translator.php
  3. 22
      tests/compiler/namespace/namespace-ending-comment.phpt

@ -321,6 +321,8 @@ class Preprocessor extends CompilerBase
case 'Stmt_Interface':
$this->parseInterface($v2);
break;
case 'Stmt_Nop':
break;
default:
$this->foundStrayCode($v2);
break;

@ -2514,6 +2514,8 @@ CODE;
case 'Stmt_Interface':
$this->validateInterfaceOverrideAttributes($v2);
break;
case 'Stmt_Nop':
break;
default:
abort($v2);
break;

@ -0,0 +1,22 @@
--TEST--
A namespace block ending with a comment must not be treated as stray code
--FILE--
<?php
declare(strict_types=1);
namespace Test {
// test
}
namespace {
function main()
{
var_dump('done');
}
// test1
}
?>
--EXPECT--
string(4) "done"
Loading…
Cancel
Save