class ClassManifest

A utility class which builds a manifest of all classes, interfaces and caches it.

It finds the following information: - Class and interface names and paths. - All direct and indirect descendants of a class. - All implementors of an interface.

To be consistent; In general all array keys are lowercase, and array values are correct-case

Methods

__construct(string $base, CacheFactory $cacheFactory = null)

Constructs and initialises a new class manifest, either loading the data from the cache or re-scanning for classes.

init(bool $includeTests = false, bool $forceRegen = false)

Initialise the class manifest

Parser
getParser()

Get or create active parser

NodeTraverser
getTraverser()

Get node traverser for parsing class files

getVisitor()

Get visitor for parsing class files

string|null
getItemPath(string $name)

Returns the file path to a class or interface if it exists in the manifest.

string
getItemName(string $name)

Return correct case name

array
getClasses()

Returns a map of lowercased class names to file paths.

array
getClassNames()

Returns a map of lowercase class names to proper class names in the manifest

array
getTraits()

Returns a map of lowercased trait names to file paths.

array
getTraitNames()

Returns a map of lowercase trait names to proper trait names in the manifest

array
getDescendants()

Returns an array of all the descendant data.

array
getDescendantsOf(string|object $class)

Returns an array containing all the descendants (direct and indirect) of a class.

array
getInterfaces()

Returns a map of lowercased interface names to file locations.

array
getInterfaceNames()

Return map of lowercase interface names to proper case names in the manifest

array
getImplementors()

Returns a map of lowercased interface names to the classes the implement them.

array
getImplementorsOf(string $interface)

Returns an array containing the class names that implement a certain interface.

getOwnerModule(string $class)

Get module that owns this class

regenerate(bool $includeTests)

Completely regenerates the manifest file.

handleFile(string $basename, string $pathname, bool $includeTests)

Visit a file to inspect for classes, interfaces and traits

Details

at line 185
__construct(string $base, CacheFactory $cacheFactory = null)

Constructs and initialises a new class manifest, either loading the data from the cache or re-scanning for classes.

Parameters

string $base The manifest base path.
CacheFactory $cacheFactory Optional cache to use. Set to null to not cache.

at line 264
init(bool $includeTests = false, bool $forceRegen = false)

Initialise the class manifest

Parameters

bool $includeTests
bool $forceRegen

at line 286
Parser getParser()

Get or create active parser

Return Value

Parser

at line 300
NodeTraverser getTraverser()

Get node traverser for parsing class files

Return Value

NodeTraverser

at line 316
ClassManifestVisitor getVisitor()

Get visitor for parsing class files

Return Value

ClassManifestVisitor

at line 332
string|null getItemPath(string $name)

Returns the file path to a class or interface if it exists in the manifest.

Parameters

string $name

Return Value

string|null

at line 353
string getItemName(string $name)

Return correct case name

Parameters

string $name

Return Value

string Correct case name

at line 373
array getClasses()

Returns a map of lowercased class names to file paths.

Return Value

array

at line 383
array getClassNames()

Returns a map of lowercase class names to proper class names in the manifest

Return Value

array

at line 393
array getTraits()

Returns a map of lowercased trait names to file paths.

Return Value

array

at line 403
array getTraitNames()

Returns a map of lowercase trait names to proper trait names in the manifest

Return Value

array

at line 413
array getDescendants()

Returns an array of all the descendant data.

Return Value

array

at line 425
array getDescendantsOf(string|object $class)

Returns an array containing all the descendants (direct and indirect) of a class.

Parameters

string|object $class

Return Value

array

at line 444
array getInterfaces()

Returns a map of lowercased interface names to file locations.

Return Value

array

at line 454
array getInterfaceNames()

Return map of lowercase interface names to proper case names in the manifest

Return Value

array

at line 465
array getImplementors()

Returns a map of lowercased interface names to the classes the implement them.

Return Value

array

at line 477
array getImplementorsOf(string $interface)

Returns an array containing the class names that implement a certain interface.

Parameters

string $interface

Return Value

array

at line 493
Module getOwnerModule(string $class)

Get module that owns this class

Parameters

string $class Class name

Return Value

Module

at line 504
regenerate(bool $includeTests)

Completely regenerates the manifest file.

Parameters

bool $includeTests

at line 544
handleFile(string $basename, string $pathname, bool $includeTests)

Visit a file to inspect for classes, interfaces and traits

Parameters

string $basename
string $pathname
bool $includeTests

Exceptions

Exception