PhpDumper
extends Dumper
in package
PhpDumper dumps a service container as a PHP class.
Tags
Table of Contents
- FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz'
- Characters that might appear in the generated variable name as first character.
- NON_FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_'
- Characters that might appear in the generated variable name as any but the first character.
- $container : mixed
- $addGetService : mixed
- $addThrow : mixed
- $asFiles : mixed
- $baseClass : mixed
- $circularReferences : mixed
- $definitionVariables : SplObjectStorage<Definition, Variable>|null
- $docStar : mixed
- $dynamicParameters : mixed
- $exportedVariables : mixed
- $expressionLanguage : mixed
- $hasProxyDumper : mixed
- $hotPathTag : mixed
- $inlinedDefinitions : mixed
- $inlinedRequires : mixed
- $inlineFactories : mixed
- $inlineRequires : mixed
- $locatedIds : mixed
- $namespace : mixed
- $preload : mixed
- $preloadTags : mixed
- $proxyDumper : DumperInterface
- $referenceVariables : mixed
- $reservedVariables : mixed
- $serviceCalls : mixed
- $serviceIdToMethodNameMap : mixed
- $serviceLocatorTag : mixed
- $singleUsePrivateIds : mixed
- $targetDirMaxMatches : mixed
- $targetDirRegex : mixed
- $usedMethodNames : mixed
- $variableCount : mixed
- __construct() : mixed
- dump() : string|array<string|int, mixed>
- Dumps the service container as a PHP class.
- setProxyDumper() : mixed
- Sets the dumper to be used when dumping proxies in the generated container.
- addAliases() : string
- addCircularReferences() : mixed
- addDefaultParametersMethod() : string
- addDeprecatedAliases() : string
- addFileMap() : string
- addInlineReference() : string
- addInlineRequires() : string
- addInlineService() : string
- addInlineVariables() : string
- addMethodMap() : string
- addNewInstance() : string
- addRemovedIds() : string
- addService() : array<string|int, mixed>
- addServiceConfigurator() : string
- addServiceInclude() : string
- addServiceInstance() : string
- addServiceMethodCalls() : string
- addServiceProperties() : string
- addServices() : string
- addSyntheticIds() : string
- analyzeReferences() : mixed
- collectCircularReferences() : void
- collectLineage() : mixed
- doExport() : mixed
- dumpLiteralClass() : string
- Dumps a string to a literal (aka PHP Code) class value.
- dumpParameter() : string
- dumpValue() : string
- endClass() : string
- export() : mixed
- exportParameters() : string
- generateMethodName() : string
- generateProxyClasses() : array<string|int, mixed>
- generateServiceFiles() : iteratable<string|int, mixed>
- getAutoloadFile() : string|null
- getClasses() : array<string|int, mixed>
- getDefinitionsFromArguments() : SplObjectStorage
- getExpressionLanguage() : ExpressionLanguage
- getNextVariableName() : string
- getProxyDumper() : DumperInterface
- Retrieves the currently set proxy dumper or instantiates one.
- getServiceCall() : string
- getServiceConditionals() : string
- initializeMethodNamesMap() : mixed
- Initializes the method names map to avoid conflicts with the Container methods.
- isHotPath() : bool
- isSingleUsePrivateNode() : bool
- isTrivialInstance() : bool
- startClass() : string
- wrapServiceConditionals() : string
Constants
FIRST_CHARS
Characters that might appear in the generated variable name as first character.
public
mixed
FIRST_CHARS
= 'abcdefghijklmnopqrstuvwxyz'
NON_FIRST_CHARS
Characters that might appear in the generated variable name as any but the first character.
public
mixed
NON_FIRST_CHARS
= 'abcdefghijklmnopqrstuvwxyz0123456789_'
Properties
$container
protected
mixed
$container
$addGetService
private
mixed
$addGetService
= false
$addThrow
private
mixed
$addThrow
= false
$asFiles
private
mixed
$asFiles
$baseClass
private
mixed
$baseClass
$circularReferences
private
mixed
$circularReferences
= []
$definitionVariables
private
SplObjectStorage<Definition, Variable>|null
$definitionVariables
$docStar
private
mixed
$docStar
$dynamicParameters
private
mixed
$dynamicParameters
= []
$exportedVariables
private
mixed
$exportedVariables
= []
$expressionLanguage
private
mixed
$expressionLanguage
$hasProxyDumper
private
mixed
$hasProxyDumper
= false
$hotPathTag
private
mixed
$hotPathTag
$inlinedDefinitions
private
mixed
$inlinedDefinitions
$inlinedRequires
private
mixed
$inlinedRequires
= []
$inlineFactories
private
mixed
$inlineFactories
$inlineRequires
private
mixed
$inlineRequires
$locatedIds
private
mixed
$locatedIds
= []
$namespace
private
mixed
$namespace
$preload
private
mixed
$preload
= []
$preloadTags
private
mixed
$preloadTags
$proxyDumper
private
DumperInterface
$proxyDumper
$referenceVariables
private
mixed
$referenceVariables
$reservedVariables
private
mixed
$reservedVariables
= ['instance', 'class', 'this', 'container']
$serviceCalls
private
mixed
$serviceCalls
$serviceIdToMethodNameMap
private
mixed
$serviceIdToMethodNameMap
$serviceLocatorTag
private
mixed
$serviceLocatorTag
$singleUsePrivateIds
private
mixed
$singleUsePrivateIds
= []
$targetDirMaxMatches
private
mixed
$targetDirMaxMatches
$targetDirRegex
private
mixed
$targetDirRegex
$usedMethodNames
private
mixed
$usedMethodNames
$variableCount
private
mixed
$variableCount
Methods
__construct()
public
__construct(ContainerBuilder $container) : mixed
Parameters
- $container : ContainerBuilder
Return values
mixed —dump()
Dumps the service container as a PHP class.
public
dump([array<string|int, mixed> $options = [] ]) : string|array<string|int, mixed>
Available options:
- class: The class name
- base_class: The base class name
- namespace: The class namespace
- as_files: To split the container in several files
Parameters
- $options : array<string|int, mixed> = []
Tags
Return values
string|array<string|int, mixed> —A PHP class representing the service container or an array of PHP files if the "as_files" option is set
setProxyDumper()
Sets the dumper to be used when dumping proxies in the generated container.
public
setProxyDumper(DumperInterface $proxyDumper) : mixed
Parameters
- $proxyDumper : DumperInterface
Return values
mixed —addAliases()
private
addAliases() : string
Return values
string —addCircularReferences()
private
addCircularReferences(string $sourceId, array<string|int, mixed> $currentPath, bool $byConstructor) : mixed
Parameters
- $sourceId : string
- $currentPath : array<string|int, mixed>
- $byConstructor : bool
Return values
mixed —addDefaultParametersMethod()
private
addDefaultParametersMethod() : string
Return values
string —addDeprecatedAliases()
private
addDeprecatedAliases() : string
Return values
string —addFileMap()
private
addFileMap() : string
Return values
string —addInlineReference()
private
addInlineReference(string $id, Definition $definition, string $targetId, bool $forConstructor) : string
Parameters
- $id : string
- $definition : Definition
- $targetId : string
- $forConstructor : bool
Return values
string —addInlineRequires()
private
addInlineRequires(bool $hasProxyClasses) : string
Parameters
- $hasProxyClasses : bool
Return values
string —addInlineService()
private
addInlineService(string $id, Definition $definition[, Definition|null $inlineDef = null ][, bool $forConstructor = true ]) : string
Parameters
- $id : string
- $definition : Definition
- $inlineDef : Definition|null = null
- $forConstructor : bool = true
Return values
string —addInlineVariables()
private
addInlineVariables(string $id, Definition $definition, array<string|int, mixed> $arguments, bool $forConstructor) : string
Parameters
- $id : string
- $definition : Definition
- $arguments : array<string|int, mixed>
- $forConstructor : bool
Return values
string —addMethodMap()
private
addMethodMap() : string
Return values
string —addNewInstance()
private
addNewInstance(Definition $definition[, string $return = '' ][, string|null $id = null ]) : string
Parameters
- $definition : Definition
- $return : string = ''
- $id : string|null = null
Return values
string —addRemovedIds()
private
addRemovedIds() : string
Return values
string —addService()
private
addService(string $id, Definition $definition) : array<string|int, mixed>
Parameters
- $id : string
- $definition : Definition
Return values
array<string|int, mixed> —addServiceConfigurator()
private
addServiceConfigurator(Definition $definition[, string $variableName = 'instance' ]) : string
Parameters
- $definition : Definition
- $variableName : string = 'instance'
Return values
string —addServiceInclude()
private
addServiceInclude(string $cId, Definition $definition) : string
Parameters
- $cId : string
- $definition : Definition
Return values
string —addServiceInstance()
private
addServiceInstance(string $id, Definition $definition, bool $isSimpleInstance) : string
Parameters
- $id : string
- $definition : Definition
- $isSimpleInstance : bool
Tags
Return values
string —addServiceMethodCalls()
private
addServiceMethodCalls(Definition $definition, string $variableName, string|null $sharedNonLazyId) : string
Parameters
- $definition : Definition
- $variableName : string
- $sharedNonLazyId : string|null
Return values
string —addServiceProperties()
private
addServiceProperties(Definition $definition[, string $variableName = 'instance' ]) : string
Parameters
- $definition : Definition
- $variableName : string = 'instance'
Return values
string —addServices()
private
addServices([array<string|int, mixed>|null &$services = null ]) : string
Parameters
- $services : array<string|int, mixed>|null = null
Return values
string —addSyntheticIds()
private
addSyntheticIds() : string
Return values
string —analyzeReferences()
private
analyzeReferences() : mixed
Return values
mixed —collectCircularReferences()
private
collectCircularReferences(string $sourceId, array<string|int, mixed> $edges, array<string|int, mixed> &$checkedNodes[, array<string|int, mixed> &$loops = [] ][, array<string|int, mixed> $path = [] ][, bool $byConstructor = true ]) : void
Parameters
- $sourceId : string
- $edges : array<string|int, mixed>
- $checkedNodes : array<string|int, mixed>
- $loops : array<string|int, mixed> = []
- $path : array<string|int, mixed> = []
- $byConstructor : bool = true
Return values
void —collectLineage()
private
collectLineage(string $class, array<string|int, mixed> &$lineage) : mixed
Parameters
- $class : string
- $lineage : array<string|int, mixed>
Return values
mixed —doExport()
private
doExport(mixed $value[, bool $resolveEnv = false ]) : mixed
Parameters
- $value : mixed
- $resolveEnv : bool = false
Return values
mixed —dumpLiteralClass()
Dumps a string to a literal (aka PHP Code) class value.
private
dumpLiteralClass(string $class) : string
Parameters
- $class : string
Tags
Return values
string —dumpParameter()
private
dumpParameter(string $name) : string
Parameters
- $name : string
Return values
string —dumpValue()
private
dumpValue(mixed $value[, bool $interpolate = true ]) : string
Parameters
- $value : mixed
- $interpolate : bool = true
Tags
Return values
string —endClass()
private
endClass() : string
Return values
string —export()
private
export(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —exportParameters()
private
exportParameters(array<string|int, mixed> $parameters[, string $path = '' ][, int $indent = 12 ][, bool &$hasEnum = false ]) : string
Parameters
- $parameters : array<string|int, mixed>
- $path : string = ''
- $indent : int = 12
- $hasEnum : bool = false
Tags
Return values
string —generateMethodName()
private
generateMethodName(string $id) : string
Parameters
- $id : string
Tags
Return values
string —generateProxyClasses()
private
generateProxyClasses() : array<string|int, mixed>
Return values
array<string|int, mixed> —generateServiceFiles()
private
generateServiceFiles(array<string|int, mixed> $services) : iteratable<string|int, mixed>
Parameters
- $services : array<string|int, mixed>
Return values
iteratable<string|int, mixed> —getAutoloadFile()
private
getAutoloadFile() : string|null
Return values
string|null —getClasses()
private
getClasses(Definition $definition, string $id) : array<string|int, mixed>
Parameters
- $definition : Definition
- $id : string
Return values
array<string|int, mixed> —getDefinitionsFromArguments()
private
getDefinitionsFromArguments(array<string|int, mixed> $arguments[, SplObjectStorage|null $definitions = null ][, array<string|int, mixed> &$calls = [] ][, bool|null $byConstructor = null ]) : SplObjectStorage
Parameters
- $arguments : array<string|int, mixed>
- $definitions : SplObjectStorage|null = null
- $calls : array<string|int, mixed> = []
- $byConstructor : bool|null = null
Return values
SplObjectStorage —getExpressionLanguage()
private
getExpressionLanguage() : ExpressionLanguage
Return values
ExpressionLanguage —getNextVariableName()
private
getNextVariableName() : string
Return values
string —getProxyDumper()
Retrieves the currently set proxy dumper or instantiates one.
private
getProxyDumper() : DumperInterface
Return values
DumperInterface —getServiceCall()
private
getServiceCall(string $id[, Reference|null $reference = null ]) : string
Parameters
- $id : string
- $reference : Reference|null = null
Return values
string —getServiceConditionals()
private
getServiceConditionals(mixed $value) : string
Parameters
- $value : mixed
Return values
string —initializeMethodNamesMap()
Initializes the method names map to avoid conflicts with the Container methods.
private
initializeMethodNamesMap(string $class) : mixed
Parameters
- $class : string
Return values
mixed —isHotPath()
private
isHotPath(Definition $definition) : bool
Parameters
- $definition : Definition
Return values
bool —isSingleUsePrivateNode()
private
isSingleUsePrivateNode(ServiceReferenceGraphNode $node) : bool
Parameters
- $node : ServiceReferenceGraphNode
Return values
bool —isTrivialInstance()
private
isTrivialInstance(Definition $definition) : bool
Parameters
- $definition : Definition
Return values
bool —startClass()
private
startClass(string $class, string $baseClass, bool $hasProxyClasses) : string
Parameters
- $class : string
- $baseClass : string
- $hasProxyClasses : bool
Return values
string —wrapServiceConditionals()
private
wrapServiceConditionals(mixed $value, string $code) : string
Parameters
- $value : mixed
- $code : string