Skip to content

Commit

Permalink
minor #23613 [DI] Remove unused props from the PhpDumper (dunglas)
Browse files Browse the repository at this point in the history
This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #23613).

Discussion
----------

[DI] Remove unused props from the PhpDumper

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

f1aa45c [DI] Remove unused props from the PhpDumper
  • Loading branch information
nicolas-grekas committed Jul 28, 2017
2 parents 3f31266 + f1aa45c commit 27a6c1f
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Expand Up @@ -255,12 +255,11 @@ private function addProxyClasses()
/**
* Generates the require_once statement for service includes.
*
* @param string $id The service id
* @param Definition $definition
*
* @return string
*/
private function addServiceInclude($id, $definition)
private function addServiceInclude($definition)
{
$template = " require_once %s;\n";
$code = '';
Expand Down Expand Up @@ -335,9 +334,9 @@ private function addServiceInlinedDefinitions($id, $definition)
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');

if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
$code .= $this->addServiceProperties(null, $sDefinition, $name);
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
$code .= $this->addServiceConfigurator(null, $sDefinition, $name);
$code .= $this->addServiceProperties($sDefinition, $name);
$code .= $this->addServiceMethodCalls($sDefinition, $name);
$code .= $this->addServiceConfigurator($sDefinition, $name);
}

$code .= "\n";
Expand Down Expand Up @@ -437,13 +436,12 @@ private function isSimpleInstance($id, Definition $definition)
/**
* Adds method calls to a service definition.
*
* @param string $id
* @param Definition $definition
* @param string $variableName
*
* @return string
*/
private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance')
private function addServiceMethodCalls(Definition $definition, $variableName = 'instance')
{
$calls = '';
foreach ($definition->getMethodCalls() as $call) {
Expand All @@ -458,7 +456,7 @@ private function addServiceMethodCalls($id, Definition $definition, $variableNam
return $calls;
}

private function addServiceProperties($id, Definition $definition, $variableName = 'instance')
private function addServiceProperties(Definition $definition, $variableName = 'instance')
{
$code = '';
foreach ($definition->getProperties() as $name => $value) {
Expand Down Expand Up @@ -501,9 +499,9 @@ private function addServiceInlinedDefinitionsSetup($id, Definition $definition)
}

$name = (string) $this->definitionVariables->offsetGet($iDefinition);
$code .= $this->addServiceProperties(null, $iDefinition, $name);
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
$code .= $this->addServiceConfigurator(null, $iDefinition, $name);
$code .= $this->addServiceProperties($iDefinition, $name);
$code .= $this->addServiceMethodCalls($iDefinition, $name);
$code .= $this->addServiceConfigurator($iDefinition, $name);
}

if ('' !== $code) {
Expand All @@ -516,13 +514,12 @@ private function addServiceInlinedDefinitionsSetup($id, Definition $definition)
/**
* Adds configurator definition.
*
* @param string $id
* @param Definition $definition
* @param string $variableName
*
* @return string
*/
private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance')
private function addServiceConfigurator(Definition $definition, $variableName = 'instance')
{
if (!$callable = $definition->getConfigurator()) {
return '';
Expand Down Expand Up @@ -633,14 +630,14 @@ private function addService($id, Definition $definition)
$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 {
$code .=
$this->addServiceInclude($id, $definition).
$this->addServiceInclude($definition).
$this->addServiceLocalTempVariables($id, $definition).
$this->addServiceInlinedDefinitions($id, $definition).
$this->addServiceInstance($id, $definition).
$this->addServiceInlinedDefinitionsSetup($id, $definition).
$this->addServiceProperties($id, $definition).
$this->addServiceMethodCalls($id, $definition).
$this->addServiceConfigurator($id, $definition).
$this->addServiceProperties($definition).
$this->addServiceMethodCalls($definition).
$this->addServiceConfigurator($definition).
$this->addServiceReturn($id, $definition)
;
}
Expand Down

0 comments on commit 27a6c1f

Please sign in to comment.