Skip to content

Support __halt_compiler as a member of the top level statements #381

@TysonAndre

Description

@TysonAndre

This would allow validation test suites to pass again

  • On the top level scope, emit a new HaltCompilerStatement with haltCompilerToken, openParen, closeParen, semicolonToken, and data of type T_INLINE_HTML
  • It's a compile error on an inner statement, so not really important to parse it, but that would be with a MissingToken for data if it was parsed in an inner statement.
// Zend/zend_language_parser.y
top_statement:
//  ....
	|	T_HALT_COMPILER '(' ')' ';'
			{ $$ = zend_ast_create(ZEND_AST_HALT_COMPILER,
			      zend_ast_create_zval_from_long(zend_get_scanned_file_offset()));
			  zend_stop_lexing(); }
php > var_export(token_get_all('<?php echo 2; __halt_compiler(); ?><?php fake data'));
array (
  0 => 
  array (
    0 => 382,
    1 => '<?php ',
    2 => 1,
  ),
  1 => 
  array (
    0 => 324,
    1 => 'echo',
    2 => 1,
  ),
  2 => 
  array (
    0 => 385,
    1 => ' ',
    2 => 1,
  ),
  3 => 
  array (
    0 => 309,
    1 => '2',
    2 => 1,
  ),
  4 => ';',
  5 => 
  array (
    0 => 385,
    1 => ' ',
    2 => 1,
  ),
  6 => 
  array (
    0 => 363,
    1 => '__halt_compiler',
    2 => 1,
  ),
  7 => '(',
  8 => ')',
  9 => ';',
  10 => 
  array (
    0 => 313,
    1 => ' ?><?php fake data',
    2 => 1,
  ),
)
php > echo token_name(313);
T_INLINE_HTML

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions