PackageTreeBuilder
extends ApiDocumentationPass
in package
Rebuilds the package tree from the elements found in files.
On every compiler pass is the package tree rebuild to aid in the process of incremental updates.
If the package tree were to be persisted then both locations needed to be invalidated if a file were to change.
Attributes
- #[Stage]
- 'phpdoc.pipeline.api_documentation.compile'
- 9001
- 'Build "packages" index'
Table of Contents
Properties
Methods
- __construct() : mixed
- __invoke() : CompilableSubject
- Executes a compiler pass.
- getDescription() : string
- Returns a textual description of what this pass does for output purposes.
- process() : ApiSetDescriptor
- Actual method executed by the compiler.
- addElementsOfTypeToPackage() : void
- Adds the given elements of a specific type to their respective Package Descriptors.
- createPackageDescriptorTree() : void
- Creates a tree of PackageDescriptors based on the provided FQNN (package name).
- normalizePackageName() : string
- Converts all old-style separators into namespace-style separators.
Properties
$parser read-only
private
Parser
$parser
Methods
__construct()
public
__construct(Parser $parser) : mixed
Parameters
- $parser : Parser
__invoke()
Executes a compiler pass.
public
final __invoke(CompilableSubject $subject) : CompilableSubject
This method will execute the business logic associated with a given compiler pass and allow it to manipulate or consumer the Object Graph using the ProjectDescriptor object.
Parameters
- $subject : CompilableSubject
-
Representation of the Object Graph that can be manipulated.
Return values
CompilableSubjectgetDescription()
Returns a textual description of what this pass does for output purposes.
public
getDescription() : string
Please note that the command line will be truncated to 68 characters (
Return values
stringprocess()
Actual method executed by the compiler.
protected
process(ApiSetDescriptor $subject) : ApiSetDescriptor
Processes the given ApiSetDescriptor and returns the modified ApiSetDescriptor.
Parameters
- $subject : ApiSetDescriptor
Return values
ApiSetDescriptoraddElementsOfTypeToPackage()
Adds the given elements of a specific type to their respective Package Descriptors.
private
addElementsOfTypeToPackage(Collection<string|int, PackageInterface> $packages, array<string|int, ElementInterface> $elements, string $type) : void
This method will assign the given elements to the package as registered in the package field of that element. If a package does not exist yet it will automatically be created.
Parameters
- $packages : Collection<string|int, PackageInterface>
- $elements : array<string|int, ElementInterface>
-
Series of elements to add to their respective package.
- $type : string
-
Declares which field of the package will be populated with the given series of elements. This name will be transformed to a getter which must exist. Out of performance considerations will no effort be done to verify whether the provided type is valid.
createPackageDescriptorTree()
Creates a tree of PackageDescriptors based on the provided FQNN (package name).
private
createPackageDescriptorTree(Collection<string|int, PackageInterface> $packages, string $packageName) : void
This method will examine the package name and create a package descriptor for each part of the FQNN if it doesn't exist in the packages field of the current package (starting with the root Package in the Project Descriptor),
As an intended side effect this method also populates the elements index of the ProjectDescriptor with all created PackageDescriptors. Each index key is prefixed with a tilde (~) so that it will not conflict with other FQSEN's, such as classes or interfaces.
Parameters
- $packages : Collection<string|int, PackageInterface>
- $packageName : string
-
A FQNN of the package (and parents) to create.
Tags
normalizePackageName()
Converts all old-style separators into namespace-style separators.
private
normalizePackageName(string $packageName) : string
Please note that the trim will, by design, remove any trailing spearators. This makes it easier to
integrate in the rest of this class and allows \My[Package]
to convert to \My\Package
.
Parameters
- $packageName : string