[DI] Remove unused props from the PhpDumper
This commit is contained in:
parent
3f31266f18
commit
f1aa45c517
@ -255,12 +255,11 @@ class PhpDumper extends Dumper
|
|||||||
/**
|
/**
|
||||||
* Generates the require_once statement for service includes.
|
* Generates the require_once statement for service includes.
|
||||||
*
|
*
|
||||||
* @param string $id The service id
|
|
||||||
* @param Definition $definition
|
* @param Definition $definition
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function addServiceInclude($id, $definition)
|
private function addServiceInclude($definition)
|
||||||
{
|
{
|
||||||
$template = " require_once %s;\n";
|
$template = " require_once %s;\n";
|
||||||
$code = '';
|
$code = '';
|
||||||
@ -335,9 +334,9 @@ class PhpDumper extends Dumper
|
|||||||
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');
|
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');
|
||||||
|
|
||||||
if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
|
if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
|
||||||
$code .= $this->addServiceProperties(null, $sDefinition, $name);
|
$code .= $this->addServiceProperties($sDefinition, $name);
|
||||||
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
|
$code .= $this->addServiceMethodCalls($sDefinition, $name);
|
||||||
$code .= $this->addServiceConfigurator(null, $sDefinition, $name);
|
$code .= $this->addServiceConfigurator($sDefinition, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$code .= "\n";
|
$code .= "\n";
|
||||||
@ -437,13 +436,12 @@ class PhpDumper extends Dumper
|
|||||||
/**
|
/**
|
||||||
* Adds method calls to a service definition.
|
* Adds method calls to a service definition.
|
||||||
*
|
*
|
||||||
* @param string $id
|
|
||||||
* @param Definition $definition
|
* @param Definition $definition
|
||||||
* @param string $variableName
|
* @param string $variableName
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance')
|
private function addServiceMethodCalls(Definition $definition, $variableName = 'instance')
|
||||||
{
|
{
|
||||||
$calls = '';
|
$calls = '';
|
||||||
foreach ($definition->getMethodCalls() as $call) {
|
foreach ($definition->getMethodCalls() as $call) {
|
||||||
@ -458,7 +456,7 @@ class PhpDumper extends Dumper
|
|||||||
return $calls;
|
return $calls;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addServiceProperties($id, Definition $definition, $variableName = 'instance')
|
private function addServiceProperties(Definition $definition, $variableName = 'instance')
|
||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
foreach ($definition->getProperties() as $name => $value) {
|
foreach ($definition->getProperties() as $name => $value) {
|
||||||
@ -501,9 +499,9 @@ class PhpDumper extends Dumper
|
|||||||
}
|
}
|
||||||
|
|
||||||
$name = (string) $this->definitionVariables->offsetGet($iDefinition);
|
$name = (string) $this->definitionVariables->offsetGet($iDefinition);
|
||||||
$code .= $this->addServiceProperties(null, $iDefinition, $name);
|
$code .= $this->addServiceProperties($iDefinition, $name);
|
||||||
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
|
$code .= $this->addServiceMethodCalls($iDefinition, $name);
|
||||||
$code .= $this->addServiceConfigurator(null, $iDefinition, $name);
|
$code .= $this->addServiceConfigurator($iDefinition, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('' !== $code) {
|
if ('' !== $code) {
|
||||||
@ -516,13 +514,12 @@ class PhpDumper extends Dumper
|
|||||||
/**
|
/**
|
||||||
* Adds configurator definition.
|
* Adds configurator definition.
|
||||||
*
|
*
|
||||||
* @param string $id
|
|
||||||
* @param Definition $definition
|
* @param Definition $definition
|
||||||
* @param string $variableName
|
* @param string $variableName
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance')
|
private function addServiceConfigurator(Definition $definition, $variableName = 'instance')
|
||||||
{
|
{
|
||||||
if (!$callable = $definition->getConfigurator()) {
|
if (!$callable = $definition->getConfigurator()) {
|
||||||
return '';
|
return '';
|
||||||
@ -633,14 +630,14 @@ EOF;
|
|||||||
$code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id);
|
$code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id);
|
||||||
} else {
|
} else {
|
||||||
$code .=
|
$code .=
|
||||||
$this->addServiceInclude($id, $definition).
|
$this->addServiceInclude($definition).
|
||||||
$this->addServiceLocalTempVariables($id, $definition).
|
$this->addServiceLocalTempVariables($id, $definition).
|
||||||
$this->addServiceInlinedDefinitions($id, $definition).
|
$this->addServiceInlinedDefinitions($id, $definition).
|
||||||
$this->addServiceInstance($id, $definition).
|
$this->addServiceInstance($id, $definition).
|
||||||
$this->addServiceInlinedDefinitionsSetup($id, $definition).
|
$this->addServiceInlinedDefinitionsSetup($id, $definition).
|
||||||
$this->addServiceProperties($id, $definition).
|
$this->addServiceProperties($definition).
|
||||||
$this->addServiceMethodCalls($id, $definition).
|
$this->addServiceMethodCalls($definition).
|
||||||
$this->addServiceConfigurator($id, $definition).
|
$this->addServiceConfigurator($definition).
|
||||||
$this->addServiceReturn($id, $definition)
|
$this->addServiceReturn($id, $definition)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user