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

Collects every declaration of a parsed source tree into one index.

Methods§

public function __construct(?TypeReader $types = null)

Builds a collector that reads declarations with the given type reader.

Parameters

$types?TypeReader
Calls 2
public function build(list<ParsedFile> $files): ProgramIndex

The index of every declaration in the given files.

Parameters

$fileslist<ParsedFile>
Test cases 178
Called from 1
Calls 8
public function readClass(ClassLike $node, string $file = ''): ?ClassShape
public function readMembers(ClassLike $node): array{traits: list<string>, constants: array<string, Expr>, cases: array<string, Expr|null>, properties: array<string, TypeShape>, defaults: array<string, Expr>, assigned: array<string, true>}

Everything a class body declares, read in one pass over it.

The body is walked once and its declarations are sorted afterwards, which matters on a source tree with thousands of classes in it.

Parameters

$nodeClassLike

Returns

array{traits: list<string>, constants: array<string, Expr>, cases: array<string, Expr|null>, properties: array<string, TypeShape>, defaults: array<string, Expr>, assigned: array<string, true>}
Test cases 1
Called from 1
Calls 4
public function readAssignedProperties(ClassLike $node): array<string, true>

The properties the class body assigns to, other than by promotion.

Parameters

$nodeClassLike

Returns

array<string, true>
Test cases 1
Calls 3
public function assignmentTarget(Expr $expression): ?string
public function readParentNames(ClassLike $node): list<string>
public function readTraitNames(ClassLike $node): list<string>

The traits the declaration uses.

Parameters

$nodeClassLike

Returns

list<string>
Test cases 1
Calls 2
  • method-call NodeFinder::findInstanceOf() line 236
  • class-const TraitUse::class() line 236
public function readConstants(ClassLike $node): array<string, Expr>

The class constant expressions declared on the class-like.

Parameters

$nodeClassLike

Returns

array<string, Expr>
Test cases 1
Calls 2
  • method-call NodeFinder::findInstanceOf() line 253
  • class-const ClassConst::class() line 253
public function readEnumCases(ClassLike $node): array<string, Expr|null>

The enum case backing expressions declared on the class-like.

Parameters

$nodeClassLike

Returns

array<string, Expr|null>
Test cases 1
Calls 2
  • method-call NodeFinder::findInstanceOf() line 270
  • class-const EnumCase::class() line 270
public function readPromotedProperties(ClassMethod $method): array<string, TypeShape>

The properties a constructor promotes.

Parameters

$methodClassMethod

Returns

array<string, TypeShape>
Test cases 1
Called from 1
Calls 3
public function readMethod(
    string $className,
    ClassMethod $method,
    string $file = '',
): MethodShape

The shape of one method declaration.

Parameters

$classNamestring
$methodClassMethod
$filestring
Test cases 1
Called from 1
Calls 4
public function readParameters(array<array-key, Param> $params): list<ParameterShape>

Private surface 2§

Implementation details, listed for orientation only.

private NodeFinder $finder
private TypeReader $types

Test cases 199§

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

Dedicated tests 15
Other tests reaching this symbol 184

Relations§

Instantiated in 1
Method calls 1
Type declarations 1