Skip to content

PHP-Parser 5.0.0 Beta 1

Pre-release
Pre-release
Compare
Choose a tag to compare
@nikic nikic released this 17 Sep 18:23
· 52 commits to 4.x since this release

See UPGRADE-5.0 for detailed migration instructions. The changelog is relative to alpha 3.

Added

  • Visitors can now be passed directly to the NodeTraverser constructor. A separate call to addVisitor() is no longer required.

Changed

  • The minimum host PHP version is now PHP 7.4. It is still possible to parse code from older versions. Property types have been added where possible.
  • The Lexer no longer accepts options. Lexer\Emulative only accepts a PhpVersion. The startLexing(), getTokens() and handleHaltCompiler() methods have been removed. Instead, there is a single method tokenize() returning the tokens.
  • The Parser::getLexer() method has been replaced by Parser::getTokens().
  • Attribute handling has been moved from the lexer to the parser, and is no longer configurable. The comments, startLine, endLine, startTokenPos, endTokenPos, startFilePos, and endFilePos attributes will always be added.
  • The pretty printer now defaults to PHP 7.4 as the target version.
  • The pretty printer now indents heredoc/nowdoc strings if the target version is >= 7.3 (flexible heredoc/nowdoc).

Removed

  • The deprecated Comment::getLine(), Comment::getTokenPos() and Comment::getFilePos() methods have been removed. Use Comment::getStartLine(), Comment::getStartTokenPos() and Comment::getStartFilePos() instead.

Deprecated

  • The Node::getLine() method has been deprecated. Use Node::getStartLine() instead.