Linker extends ApiDocumentationPass
in package

The linker contains all rules to replace FQSENs in the ProjectDescriptor with aliases to objects.

This object contains a list of class FQCNs for Descriptors and their associated linker rules.

An example scenario should be:

The Descriptor ``\phpDocumentor\Descriptor\ClassDescriptor`` has a *Substitute* rule determining that the
contents of the ``Parent`` field should be substituted with another ClassDescriptor with the FQCN
represented by the value of the Parent field. In addition (second element) it has an *Analyse* rule
specifying that the contents of the ``Methods`` field should be interpreted by the linker. Because that field
contains an array or Descriptor Collection will each element be analysed by the linker.

As can be seen in the above example is it possible to analyse a tree structure and substitute FQSENs where encountered.

Table of Contents




$descriptorRepository  : DescriptorRepository
$processedObjects  : array<string|int, string>
$substitutions  : array<string|int, mixed>


__construct()  : mixed
Initializes the linker with a series of Descriptors to link to.
__invoke()  : CompilableSubject
Executes a compiler pass.
getDescription()  : string
getSubstitutions()  : array<string|int, array<string|int, string>>
Returns the list of substitutions for the linker.
substitute()  : string|DocumentationSetDescriptor|DescriptorAbstract|Collection<string|int, string|DescriptorAbstract>|array<string|int, string|DescriptorAbstract>|null
Substitutes the given item or its children's FQCN with an object alias.
process()  : ApiSetDescriptor
findFieldValue()  : string|object
Returns the value of a field in the given object.
isDescriptorContainer()  : bool
Returns true if the given Descriptor is a container type.
substituteChildrenOfCollection()  : array<string|int, string|DescriptorAbstract>|Collection<string|int, string|DescriptorAbstract>|null
substituteMembersOfObject()  : void



public final mixed COMPILER_PRIORITY = 10000



private array<string|int, string> $processedObjects = []

Prevent cycles by tracking which objects have been analyzed

$substitutions read-only

private array<string|int, mixed> $substitutions



Initializes the linker with a series of Descriptors to link to.

public __construct(array<class-string, array<string|int, string>> $substitutions, DescriptorRepository $descriptorRepository) : mixed
$substitutions : array<class-string, array<string|int, string>>
$descriptorRepository : DescriptorRepository


public getDescription() : string
Return values


Returns the list of substitutions for the linker.

public getSubstitutions() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>>


Substitutes the given item or its children's FQCN with an object alias.

public substitute(string|Fqsen|Type|Collection<string|int, mixed>|array<string|int, mixed>|Descriptor|DocumentationSetDescriptor $item[, DescriptorAbstract|null $container = null ]) : string|DocumentationSetDescriptor|DescriptorAbstract|Collection<string|int, string|DescriptorAbstract>|array<string|int, string|DescriptorAbstract>|null

This method may do either of the following depending on the item's type

FQSEN or String If the given item is a string then this method will attempt to find an appropriate Class, Interface or TraitDescriptor object and return that. See DescriptorRepository::findAlias() for more information on the normalization of these strings.

Array or Traversable Iterate through each item, pass each key's contents to a new call to substitute and replace the key's contents if the contents is not an object (objects automatically update and this saves performance).

Object Determines all eligible substitutions using the substitutions property, construct a getter and retrieve the field's contents. Pass these contents to a new call of substitute and use a setter to replace the field's contents if anything other than null is returned.

The Container is a descriptor that acts as container for all elements underneath or null if there is no current container.

This method will return null if no substitution was possible and all of the above should not update the parent item when null is passed.

$item : string|Fqsen|Type|Collection<string|int, mixed>|array<string|int, mixed>|Descriptor|DocumentationSetDescriptor
$container : DescriptorAbstract|null = null
Return values
string|DocumentationSetDescriptor|DescriptorAbstract|Collection<string|int, string|DescriptorAbstract>|array<string|int, string|DescriptorAbstract>|null


Returns the value of a field in the given object.

private findFieldValue(object $object, string $fieldName) : string|object
$object : object
$fieldName : string
Return values


Returns true if the given Descriptor is a container type.

private isDescriptorContainer(object $item) : bool
$item : object

DescriptorAbstract $item

Return values


private substituteChildrenOfCollection(array<string|int, string|DescriptorAbstract>|Collection<string|int, string|DescriptorAbstract$collection, DescriptorAbstract|null $container) : array<string|int, string|DescriptorAbstract>|Collection<string|int, string|DescriptorAbstract>|null
$collection : array<string|int, string|DescriptorAbstract>|Collection<string|int, string|DescriptorAbstract>
$container : DescriptorAbstract|null
Return values
array<string|int, string|DescriptorAbstract>|Collection<string|int, string|DescriptorAbstract>|null

On this page

Search results