updated core and modules
This commit is contained in:
+57
-33
@@ -144,6 +144,7 @@ class PhpDumper extends Dumper
|
||||
if ($this->container->isFrozen()) {
|
||||
$code .= $this->addFrozenConstructor();
|
||||
$code .= $this->addFrozenCompile();
|
||||
$code .= $this->addIsFrozenMethod();
|
||||
} else {
|
||||
$code .= $this->addConstructor();
|
||||
}
|
||||
@@ -334,8 +335,8 @@ class PhpDumper extends Dumper
|
||||
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');
|
||||
|
||||
if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
|
||||
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
|
||||
$code .= $this->addServiceProperties(null, $sDefinition, $name);
|
||||
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
|
||||
$code .= $this->addServiceConfigurator(null, $sDefinition, $name);
|
||||
}
|
||||
|
||||
@@ -374,7 +375,7 @@ class PhpDumper extends Dumper
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function addServiceInstance($id, $definition)
|
||||
private function addServiceInstance($id, Definition $definition)
|
||||
{
|
||||
$class = $definition->getClass();
|
||||
|
||||
@@ -424,7 +425,7 @@ class PhpDumper extends Dumper
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isSimpleInstance($id, $definition)
|
||||
private function isSimpleInstance($id, Definition $definition)
|
||||
{
|
||||
foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) {
|
||||
if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) {
|
||||
@@ -448,7 +449,7 @@ class PhpDumper extends Dumper
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function addServiceMethodCalls($id, $definition, $variableName = 'instance')
|
||||
private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance')
|
||||
{
|
||||
$calls = '';
|
||||
foreach ($definition->getMethodCalls() as $call) {
|
||||
@@ -463,7 +464,7 @@ class PhpDumper extends Dumper
|
||||
return $calls;
|
||||
}
|
||||
|
||||
private function addServiceProperties($id, $definition, $variableName = 'instance')
|
||||
private function addServiceProperties($id, Definition $definition, $variableName = 'instance')
|
||||
{
|
||||
$code = '';
|
||||
foreach ($definition->getProperties() as $name => $value) {
|
||||
@@ -483,7 +484,7 @@ class PhpDumper extends Dumper
|
||||
*
|
||||
* @throws ServiceCircularReferenceException when the container contains a circular reference
|
||||
*/
|
||||
private function addServiceInlinedDefinitionsSetup($id, $definition)
|
||||
private function addServiceInlinedDefinitionsSetup($id, Definition $definition)
|
||||
{
|
||||
$this->referenceVariables[$id] = new Variable('instance');
|
||||
|
||||
@@ -506,8 +507,8 @@ class PhpDumper extends Dumper
|
||||
}
|
||||
|
||||
$name = (string) $this->definitionVariables->offsetGet($iDefinition);
|
||||
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
|
||||
$code .= $this->addServiceProperties(null, $iDefinition, $name);
|
||||
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
|
||||
$code .= $this->addServiceConfigurator(null, $iDefinition, $name);
|
||||
}
|
||||
|
||||
@@ -527,7 +528,7 @@ class PhpDumper extends Dumper
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function addServiceConfigurator($id, $definition, $variableName = 'instance')
|
||||
private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance')
|
||||
{
|
||||
if (!$callable = $definition->getConfigurator()) {
|
||||
return '';
|
||||
@@ -559,7 +560,7 @@ class PhpDumper extends Dumper
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function addService($id, $definition)
|
||||
private function addService($id, Definition $definition)
|
||||
{
|
||||
$this->definitionVariables = new \SplObjectStorage();
|
||||
$this->referenceVariables = array();
|
||||
@@ -570,22 +571,22 @@ class PhpDumper extends Dumper
|
||||
if ($definition->isSynthetic()) {
|
||||
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
|
||||
} elseif ($class = $definition->getClass()) {
|
||||
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
|
||||
$return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
|
||||
} elseif ($definition->getFactory()) {
|
||||
$factory = $definition->getFactory();
|
||||
if (is_string($factory)) {
|
||||
$return[] = sprintf('@return object An instance returned by %s().', $factory);
|
||||
$return[] = sprintf('@return object An instance returned by %s()', $factory);
|
||||
} elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) {
|
||||
if (is_string($factory[0]) || $factory[0] instanceof Reference) {
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s().', (string) $factory[0], $factory[1]);
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s()', (string) $factory[0], $factory[1]);
|
||||
} elseif ($factory[0] instanceof Definition) {
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s().', $factory[0]->getClass(), $factory[1]);
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s()', $factory[0]->getClass(), $factory[1]);
|
||||
}
|
||||
}
|
||||
} elseif ($definition->getFactoryClass(false)) {
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(false), $definition->getFactoryMethod(false));
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s()', $definition->getFactoryClass(false), $definition->getFactoryMethod(false));
|
||||
} elseif ($definition->getFactoryService(false)) {
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryService(false), $definition->getFactoryMethod(false));
|
||||
$return[] = sprintf('@return object An instance returned by %s::%s()', $definition->getFactoryService(false), $definition->getFactoryMethod(false));
|
||||
}
|
||||
|
||||
$scope = $definition->getScope(false);
|
||||
@@ -682,8 +683,8 @@ EOF;
|
||||
$this->addServiceInlinedDefinitions($id, $definition).
|
||||
$this->addServiceInstance($id, $definition).
|
||||
$this->addServiceInlinedDefinitionsSetup($id, $definition).
|
||||
$this->addServiceMethodCalls($id, $definition).
|
||||
$this->addServiceProperties($id, $definition).
|
||||
$this->addServiceMethodCalls($id, $definition).
|
||||
$this->addServiceConfigurator($id, $definition).
|
||||
$this->addServiceReturn($id, $definition)
|
||||
;
|
||||
@@ -977,6 +978,26 @@ EOF;
|
||||
throw new LogicException('You cannot compile a dumped frozen container.');
|
||||
}
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the isFrozen method for a frozen container.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function addIsFrozenMethod()
|
||||
{
|
||||
return <<<EOF
|
||||
|
||||
/*{$this->docStar}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isFrozen()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
@@ -1008,11 +1029,7 @@ EOF;
|
||||
private function addAliases()
|
||||
{
|
||||
if (!$aliases = $this->container->getAliases()) {
|
||||
if ($this->container->isFrozen()) {
|
||||
return "\n \$this->aliases = array();\n";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return $this->container->isFrozen() ? "\n \$this->aliases = array();\n" : '';
|
||||
}
|
||||
|
||||
$code = " \$this->aliases = array(\n";
|
||||
@@ -1123,7 +1140,7 @@ EOF;
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function exportParameters($parameters, $path = '', $indent = 12)
|
||||
private function exportParameters(array $parameters, $path = '', $indent = 12)
|
||||
{
|
||||
$php = array();
|
||||
foreach ($parameters as $key => $value) {
|
||||
@@ -1288,10 +1305,17 @@ EOF;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($deep && !isset($visited[$argumentId])) {
|
||||
if ($deep && !isset($visited[$argumentId]) && 'service_container' !== $argumentId) {
|
||||
$visited[$argumentId] = true;
|
||||
|
||||
$service = $this->container->getDefinition($argumentId);
|
||||
|
||||
// if the proxy manager is enabled, disable searching for references in lazy services,
|
||||
// as these services will be instantiated lazily and don't have direct related references.
|
||||
if ($service->isLazy() && !$this->getProxyDumper() instanceof NullDumper) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties());
|
||||
|
||||
if ($this->hasReference($id, $arguments, $deep, $visited)) {
|
||||
@@ -1374,9 +1398,9 @@ EOF;
|
||||
$service = $this->dumpValue($value->getFactoryService(false));
|
||||
|
||||
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
|
||||
} else {
|
||||
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
|
||||
}
|
||||
|
||||
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
|
||||
}
|
||||
|
||||
$class = $value->getClass();
|
||||
@@ -1414,9 +1438,9 @@ EOF;
|
||||
}
|
||||
} elseif (is_object($value) || is_resource($value)) {
|
||||
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
|
||||
} else {
|
||||
return $this->export($value);
|
||||
}
|
||||
|
||||
return $this->export($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1485,13 +1509,13 @@ EOF;
|
||||
|
||||
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
||||
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
|
||||
} else {
|
||||
if ($this->container->hasAlias($id)) {
|
||||
$id = (string) $this->container->getAlias($id);
|
||||
}
|
||||
|
||||
return sprintf('$this->get(\'%s\')', $id);
|
||||
}
|
||||
|
||||
if ($this->container->hasAlias($id)) {
|
||||
$id = (string) $this->container->getAlias($id);
|
||||
}
|
||||
|
||||
return sprintf('$this->get(\'%s\')', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user