Documentation

ParserFactory
in package

Table of Contents

ONLY_PHP5  = 4
ONLY_PHP7  = 3
PREFER_PHP5  = 2
PREFER_PHP7  = 1
create()  : Parser
Creates a Parser instance, according to the provided kind.
createForHostVersion()  : Parser
Create a parser targeting the host PHP version, that is the PHP version we're currently running on. This parser will not use any token emulation.
createForNewestSupportedVersion()  : Parser
Create a parser targeting the newest version supported by this library. Code for older versions will be accepted if there have been no relevant backwards-compatibility breaks in PHP.
getLexerOptions()  : array<string|int, mixed>

Constants

Methods

create()

Creates a Parser instance, according to the provided kind.

public create(int $kind[, Lexer|null $lexer = null ][, array<string|int, mixed> $parserOptions = [] ]) : Parser
Parameters
$kind : int

One of ::PREFER_PHP7, ::PREFER_PHP5, ::ONLY_PHP7 or ::ONLY_PHP5

$lexer : Lexer|null = null

Lexer to use. Defaults to emulative lexer when not specified

$parserOptions : array<string|int, mixed> = []

Parser options. See ParserAbstract::__construct() argument

Return values
Parser

The parser instance

createForHostVersion()

Create a parser targeting the host PHP version, that is the PHP version we're currently running on. This parser will not use any token emulation.

public createForHostVersion() : Parser

All supported lexer attributes (comments, startLine, endLine, startTokenPos, endTokenPos, startFilePos, endFilePos) will be enabled.

Return values
Parser

createForNewestSupportedVersion()

Create a parser targeting the newest version supported by this library. Code for older versions will be accepted if there have been no relevant backwards-compatibility breaks in PHP.

public createForNewestSupportedVersion() : Parser

All supported lexer attributes (comments, startLine, endLine, startTokenPos, endTokenPos, startFilePos, endFilePos) will be enabled.

Return values
Parser

getLexerOptions()

private getLexerOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results