Documentation

ClassCollectionLoader
in package

ClassCollectionLoader.

Tags
author

Fabien Potencier fabien@symfony.com

deprecated

since version 3.3, to be removed in 4.0.

Table of Contents

$loaded  : mixed
$seen  : mixed
$useTokenizer  : mixed
enableTokenizer()  : mixed
This method is only useful for testing.
fixNamespaceDeclarations()  : string
Adds brackets around each namespace if it's not already the case.
inline()  : array<string|int, mixed>
Generates a file where classes and their parents are inlined.
load()  : mixed
Loads a list of classes and caches them in one big file.
compressCode()  : string
Strips leading & trailing ws, multiple EOL, multiple ws.
computeTraitDeps()  : mixed
getClassHierarchy()  : mixed
getInterfaces()  : mixed
getOrderedClasses()  : array<string|int, ReflectionClass>
Gets an ordered array of passed classes including all their dependencies.
resolveDependencies()  : ArrayObject
Dependencies resolution.
writeCacheFile()  : mixed
Writes a cache file.

Properties

Methods

enableTokenizer()

This method is only useful for testing.

public static enableTokenizer(mixed $bool) : mixed
Parameters
$bool : mixed
Return values
mixed

fixNamespaceDeclarations()

Adds brackets around each namespace if it's not already the case.

public static fixNamespaceDeclarations(string $source) : string
Parameters
$source : string

Namespace string

Return values
string

Namespaces with brackets

inline()

Generates a file where classes and their parents are inlined.

public static inline(array<string|int, mixed> $classes, string $cache, array<string|int, mixed> $excluded) : array<string|int, mixed>
Parameters
$classes : array<string|int, mixed>

An array of classes to load

$cache : string

The file where classes are inlined

$excluded : array<string|int, mixed>

An array of classes that won't be inlined

Tags
throws
RuntimeException

When class can't be loaded

Return values
array<string|int, mixed>

The source map of inlined classes, with classes as keys and files as values

load()

Loads a list of classes and caches them in one big file.

public static load(array<string|int, mixed> $classes, string $cacheDir, string $name, bool $autoReload[, bool $adaptive = false ][, string $extension = '.php' ]) : mixed
Parameters
$classes : array<string|int, mixed>

An array of classes to load

$cacheDir : string

A cache directory

$name : string

The cache name prefix

$autoReload : bool

Whether to flush the cache when the cache is stale or not

$adaptive : bool = false

Whether to remove already declared classes or not

$extension : string = '.php'

File extension of the resulting file

Tags
throws
InvalidArgumentException

When class can't be loaded

Return values
mixed

compressCode()

Strips leading & trailing ws, multiple EOL, multiple ws.

private static compressCode(string $code) : string
Parameters
$code : string

Original PHP code

Return values
string

compressed code

computeTraitDeps()

private static computeTraitDeps(ReflectionClass $class) : mixed
Parameters
$class : ReflectionClass
Return values
mixed

getClassHierarchy()

private static getClassHierarchy(ReflectionClass $class) : mixed
Parameters
$class : ReflectionClass
Return values
mixed

getInterfaces()

private static getInterfaces(ReflectionClass $class) : mixed
Parameters
$class : ReflectionClass
Return values
mixed

getOrderedClasses()

Gets an ordered array of passed classes including all their dependencies.

private static getOrderedClasses(array<string|int, mixed> $classes) : array<string|int, ReflectionClass>
Parameters
$classes : array<string|int, mixed>
Tags
throws
InvalidArgumentException

When a class can't be loaded

Return values
array<string|int, ReflectionClass>

An array of sorted \ReflectionClass instances (dependencies added if needed)

resolveDependencies()

Dependencies resolution.

private static resolveDependencies(array<string|int, mixed> $tree, ReflectionClass $node[, ArrayObject $resolved = null ][, ArrayObject $unresolved = null ]) : ArrayObject

This function does not check for circular dependencies as it should never occur with PHP traits.

Parameters
$tree : array<string|int, mixed>

The dependency tree

$node : ReflectionClass

The node

$resolved : ArrayObject = null

An array of already resolved dependencies

$unresolved : ArrayObject = null

An array of dependencies to be resolved

Tags
throws
RuntimeException

if a circular dependency is detected

Return values
ArrayObject

The dependencies for the given node

writeCacheFile()

Writes a cache file.

private static writeCacheFile(string $file, string $content) : mixed
Parameters
$file : string

Filename

$content : string

Temporary file content

Tags
throws
RuntimeException

when a cache file cannot be written

Return values
mixed

Search results