Menu

## Compiler
in package

Compiler.php : 35

Compiles the container into PHP code much more optimized for performances.

##### Tags

author

  Matthieu Napoli matthieu@mnapoli.fr

### 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

Compiler.php : 78
`private bool $autowiringEnabled`

#### $containerClass

Compiler.php : 37
`private string $containerClass`

#### $containerParentClass

Compiler.php : 39
`private string $containerParentClass`

#### $entriesToCompile

Compiler.php : 46

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

Compiler.php : 71

Map of entry names to method names.

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

#### $methodMappingCounter

Compiler.php : 64

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

Compiler.php : 76
`private array<string|int, string> $methods = []`

#### $proxyFactory

Compiler.php : 81
`private ProxyFactory $proxyFactory`

#### $subEntryCounter

Compiler.php : 55

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()

Compiler.php : 80
`public __construct(ProxyFactory $proxyFactory) : mixed`

##### Parameters

$proxyFactory : ProxyFactory

#### compile()

Compiler.php : 95

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()

Compiler.php : 302
`public compileValue(mixed $value) : string`

##### Parameters

$value : mixed

##### Return values

string

#### getProxyFactory()

Compiler.php : 85
`public getProxyFactory() : ProxyFactory`

##### Return values

ProxyFactory

#### compileClosure()

Compiler.php : 384
`private compileClosure(Closure $closure) : string`

##### Parameters

$closure : Closure

##### Tags

throws
  InvalidDefinition

##### Return values

string

#### compileDefinition()

Compiler.php : 197
`private compileDefinition(string $entryName, Definition $definition) : string`

##### Parameters

$entryName : string
$definition : Definition

##### Tags

throws
  DependencyException
throws
  InvalidDefinition

##### Return values

string —

The method name

#### createCompilationDirectory()

Compiler.php : 339
`private createCompilationDirectory(string $directory) : void`

##### Parameters

$directory : string

#### isCompilable()

Compiler.php : 352
`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()

Compiler.php : 166
`private writeFileAtomic(string $fileName, string $content) : void`

##### Parameters

$fileName : string
$content : string

## Search results