Skip to content

Commit 1f91209

Browse files
committed
implement T_HALT_COMPILER token
1 parent 0ae7bc0 commit 1f91209

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/parser/statement.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ module.exports = {
6464
return this.next().read_const_list();
6565
case this.tok.T_NAMESPACE:
6666
return this.read_namespace();
67+
case this.tok.T_HALT_COMPILER:
68+
var result = this.node('halt');
69+
this.next().expect('(').next().expect(')').next().expect(';');
70+
this.lexer.done = true;
71+
return result(this.lexer._input.substring(
72+
this.lexer.offset
73+
));
6774
default:
6875
return this.read_statement();
6976
}
@@ -146,7 +153,9 @@ module.exports = {
146153
return this.read_interface(0);
147154
case this.tok.T_TRAIT:
148155
return this.read_trait();
149-
// @todo T_HALT_COMPILER '(' ')' ';'
156+
case this.tok.T_HALT_COMPILER:
157+
this.next().expect('(').next().expect(')').next().expect(';').next();
158+
this.raiseError('__HALT_COMPILER() can only be used from the outermost scope');
150159
default:
151160
return this.read_statement();
152161
}

0 commit comments

Comments
 (0)