final class SourceParser
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Turns PHP source into a statement tree with fully qualified names.

Methods§

public function __construct()

Builds a parser for the newest PHP version the installed library supports.

Calls 5
  • method-call ParserFactory::createForNewestSupportedVersion() line 31
  • new ParserFactory line 31
  • new NodeTraverser line 32
  • new NameResolver line 32
  • new ParentConnectingVisitor line 32
public function parse(string $path, string $code): ParsedFile

Parses source text that was read from the given path.

Parse errors are collected rather than thrown, so the first one can name the file it came from instead of arriving as a bare parser message.

Parameters

$pathstringThe path reported in errors and recorded on the result
$codestringThe source text

Returns

Throws

SyntaxException When the source is not valid PHP
Test cases 383
Called from 1
Calls 6
public function resolveNames(array<array-key, Stmt> $statements): list<Stmt>

The statements with every name resolved and every parent link connected.

Parameters

$statementsarray<array-key, Stmt>

Returns

list<Stmt>
Test cases 1
Called from 1
Calls 1
  • method-call NodeTraverser::traverse() line 70

Private surface 2§

Implementation details, listed for orientation only.

private Parser $parser
private NodeTraverser $traverser

Test cases 388§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5
Other tests reaching this symbol 383

Relations§

Instantiated in 1
Method calls 1
Type declarations 1