Compiler
in package
Compiles the container into PHP code much more optimized for performances.
Tags
Table of Contents
Properties
- $autowiringEnabled : bool
- $containerClass : string
- $containerParentClass : string
- $entriesToCompile : ArrayIterator
- Definitions indexed by the entry name. The value can be null if the definition needs to be fetched.
- $entryToMethodMapping : array<string|int, string>
- Map of entry names to method names.
- $methodMappingCounter : int
- Progressive counter for CompiledContainer get methods.
- $methods : array<string|int, string>
- $proxyFactory : ProxyFactory
- $subEntryCounter : int
- Progressive counter for definitions.
Methods
- __construct() : mixed
- compile() : string
- Compile the container.
- compileValue() : string
- getProxyFactory() : ProxyFactory
- compileClosure() : string
- compileDefinition() : string
- createCompilationDirectory() : void
- isCompilable() : string|true
- writeFileAtomic() : void
Properties
$autowiringEnabled
private
bool
$autowiringEnabled
$containerClass
private
string
$containerClass
$containerParentClass
private
string
$containerParentClass
$entriesToCompile
Definitions indexed by the entry name. The value can be null if the definition needs to be fetched.
private
ArrayIterator
$entriesToCompile
Keys are strings, values are Definition objects or null.
$entryToMethodMapping
Map of entry names to method names.
private
array<string|int, string>
$entryToMethodMapping
= []
$methodMappingCounter
Progressive counter for CompiledContainer get methods.
private
int
$methodMappingCounter
= 0
Each CompiledContainer method name is defined as 'get' + counter and remains the same after each recompilation if PHP-DI configuration does not change.
$methods
private
array<string|int, string>
$methods
= []
$proxyFactory
private
ProxyFactory
$proxyFactory
$subEntryCounter
Progressive counter for definitions.
private
int
$subEntryCounter
= 0
Each key in $entriesToCompile is defined as 'SubEntry' + counter and each definition has always the same key in the CompiledContainer if PHP-DI configuration does not change.
Methods
__construct()
public
__construct(ProxyFactory $proxyFactory) : mixed
Parameters
- $proxyFactory : ProxyFactory
compile()
Compile the container.
public
compile(DefinitionSource $definitionSource, string $directory, string $className, string $parentClassName, bool $autowiringEnabled) : string
Parameters
- $definitionSource : DefinitionSource
- $directory : string
- $className : string
- $parentClassName : string
- $autowiringEnabled : bool
Return values
string —The compiled container file name.
compileValue()
public
compileValue(mixed $value) : string
Parameters
- $value : mixed
Return values
stringgetProxyFactory()
public
getProxyFactory() : ProxyFactory
Return values
ProxyFactorycompileClosure()
private
compileClosure(Closure $closure) : string
Parameters
- $closure : Closure
Tags
Return values
stringcompileDefinition()
private
compileDefinition(string $entryName, Definition $definition) : string
Parameters
- $entryName : string
- $definition : Definition
Tags
Return values
string —The method name
createCompilationDirectory()
private
createCompilationDirectory(string $directory) : void
Parameters
- $directory : string
isCompilable()
private
isCompilable(mixed $value) : string|true
Parameters
- $value : mixed
Return values
string|true —If true is returned that means that the value is compilable.
writeFileAtomic()
private
writeFileAtomic(string $fileName, string $content) : void
Parameters
- $fileName : string
- $content : string