[3.4][DI] Inline trivial services
This commit is contained in:
parent
80c0ec1cfd
commit
2a7f86f85b
@ -475,6 +475,50 @@ EOF;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the definition is a trivial instance.
|
||||
*
|
||||
* @param Definition $definition
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isTrivialInstance(Definition $definition)
|
||||
{
|
||||
if ($definition->isSynthetic() || $definition->getFile() || $definition->getMethodCalls() || $definition->getProperties() || $definition->getConfigurator()) {
|
||||
return false;
|
||||
}
|
||||
if ($definition->isDeprecated() || $definition->isLazy() || $definition->getFactory() || 3 < count($definition->getArguments())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($definition->getArguments() as $arg) {
|
||||
if (!$arg || ($arg instanceof Reference && 'service_container' !== (string) $arg)) {
|
||||
continue;
|
||||
}
|
||||
if (is_array($arg) && 3 >= count($arg)) {
|
||||
foreach ($arg as $k => $v) {
|
||||
if ($this->dumpValue($k) !== $this->dumpValue($k, false)) {
|
||||
return false;
|
||||
}
|
||||
if (!$v || ($v instanceof Reference && 'service_container' !== (string) $v)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_scalar($v) || $this->dumpValue($v) !== $this->dumpValue($v, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif (!is_scalar($arg) || $this->dumpValue($arg) !== $this->dumpValue($arg, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== strpos($this->dumpLiteralClass($this->dumpValue($definition->getClass())), '$')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds method calls to a service definition.
|
||||
*
|
||||
@ -1669,14 +1713,19 @@ EOF;
|
||||
|
||||
if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
|
||||
$code = 'null';
|
||||
} elseif ($this->asFiles && $this->container->hasDefinition($id)) {
|
||||
if ($this->container->getDefinition($id)->isShared()) {
|
||||
} elseif ($this->container->hasDefinition($id)) {
|
||||
$definition = $this->container->getDefinition($id);
|
||||
|
||||
if ($this->isTrivialInstance($definition)) {
|
||||
$code = substr($this->addNewInstance($definition, '', '', $id), 8, -2);
|
||||
if ($definition->isShared()) {
|
||||
$code = sprintf('$this->services[\'%s\'] = %s', $id, $code);
|
||||
}
|
||||
} elseif ($this->asFiles && $definition->isShared()) {
|
||||
$code = sprintf("\$this->load(__DIR__.'/%s.php')", $this->generateMethodName($id));
|
||||
} else {
|
||||
$code = sprintf('$this->%s()', $this->generateMethodName($id));
|
||||
}
|
||||
} elseif ($this->container->hasDefinition($id) && !$this->container->getDefinition($id)->isPublic()) {
|
||||
$code = sprintf('$this->%s()', $this->generateMethodName($id));
|
||||
} elseif (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
||||
$code = sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
|
||||
} else {
|
||||
|
@ -126,6 +126,7 @@ $container
|
||||
$container
|
||||
->register('factory_simple', 'SimpleFactoryClass')
|
||||
->addArgument('foo')
|
||||
->setDeprecated(true)
|
||||
->setPublic(false)
|
||||
;
|
||||
$container
|
||||
|
@ -79,7 +79,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getBarService()
|
||||
{
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
|
||||
$this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar'));
|
||||
|
||||
@ -97,7 +97,7 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$this->services['baz'] = $instance = new \Baz();
|
||||
|
||||
$instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->get('foo_with_inline')) && false ?: '_'});
|
||||
$instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->getFooWithInlineService()) && false ?: '_'});
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -125,7 +125,7 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$this->services['configured_service_simple'] = $instance = new \stdClass();
|
||||
|
||||
${($_ = isset($this->services['configurator_service_simple']) ? $this->services['configurator_service_simple'] : $this->getConfiguratorServiceSimpleService()) && false ?: '_'}->configureStdClass($instance);
|
||||
${($_ = isset($this->services['configurator_service_simple']) ? $this->services['configurator_service_simple'] : $this->services['configurator_service_simple'] = new \ConfClass('bar')) && false ?: '_'}->configureStdClass($instance);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -181,7 +181,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFactoryServiceService()
|
||||
{
|
||||
return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}->getInstance();
|
||||
return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'}->getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,14 +201,14 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFooService()
|
||||
{
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
|
||||
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')), true, $this);
|
||||
|
||||
$instance->foo = 'bar';
|
||||
$instance->moo = $a;
|
||||
$instance->qux = array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo'));
|
||||
$instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'});
|
||||
$instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->getBarService()) && false ?: '_'});
|
||||
$instance->initialize();
|
||||
sc_configure($instance);
|
||||
|
||||
@ -238,7 +238,7 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$class = $this->getParameter('foo_class');
|
||||
|
||||
return new $class(${($_ = isset($this->services['deprecated_service']) ? $this->services['deprecated_service'] : $this->get('deprecated_service')) && false ?: '_'});
|
||||
return new $class(${($_ = isset($this->services['deprecated_service']) ? $this->services['deprecated_service'] : $this->getDeprecatedServiceService()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,7 +263,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getLazyContextService()
|
||||
{
|
||||
return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () {
|
||||
yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
yield 'k2' => $this;
|
||||
}, 2), new RewindableGenerator(function () {
|
||||
return new \EmptyIterator();
|
||||
@ -278,7 +278,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getLazyContextIgnoreInvalidRefService()
|
||||
{
|
||||
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
|
||||
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
if ($this->has('invalid')) {
|
||||
yield 1 => ${($_ = isset($this->services['invalid']) ? $this->services['invalid'] : $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'};
|
||||
}
|
||||
@ -300,7 +300,7 @@ class ProjectServiceContainer extends Container
|
||||
|
||||
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
||||
|
||||
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'});
|
||||
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'});
|
||||
$instance->setBar(${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : $this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
if ($this->has('foo3')) {
|
||||
$instance->setBar(${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : $this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
@ -308,7 +308,7 @@ class ProjectServiceContainer extends Container
|
||||
if ($this->has('foobaz')) {
|
||||
$instance->setBar(${($_ = isset($this->services['foobaz']) ? $this->services['foobaz'] : $this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
}
|
||||
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
||||
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -346,7 +346,7 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$this->services['configurator_service'] = $instance = new \ConfClass();
|
||||
|
||||
$instance->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'});
|
||||
$instance->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->getBazService()) && false ?: '_'});
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -365,9 +365,13 @@ class ProjectServiceContainer extends Container
|
||||
* Gets the private 'factory_simple' shared service.
|
||||
*
|
||||
* @return \SimpleFactoryClass
|
||||
*
|
||||
* @deprecated The "factory_simple" service is deprecated. You should stop using it, as it will soon be removed.
|
||||
*/
|
||||
protected function getFactorySimpleService()
|
||||
{
|
||||
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->services['factory_simple'] = new \SimpleFactoryClass('foo');
|
||||
}
|
||||
|
||||
@ -381,7 +385,7 @@ class ProjectServiceContainer extends Container
|
||||
$this->services['inlined'] = $instance = new \Bar();
|
||||
|
||||
$instance->pub = 'pub';
|
||||
$instance->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'});
|
||||
$instance->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->getBazService()) && false ?: '_'});
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
@ -102,7 +102,18 @@ use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
|
||||
// Returns the public 'factory_service_simple' shared service.
|
||||
|
||||
return $this->services['factory_service_simple'] = (new \SimpleFactoryClass('foo'))->getInstance();
|
||||
return $this->services['factory_service_simple'] = ${($_ = isset($this->services['factory_simple']) ? $this->services['factory_simple'] : $this->load(__DIR__.'/getFactorySimpleService.php')) && false ?: '_'}->getInstance();
|
||||
|
||||
[Container%s/getFactorySimpleService.php] => <?php
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||
|
||||
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
|
||||
// Returns the private 'factory_simple' shared service.
|
||||
|
||||
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->services['factory_simple'] = new \SimpleFactoryClass('foo');
|
||||
|
||||
[Container%s/getFooService.php] => <?php
|
||||
|
||||
@ -272,6 +283,7 @@ class Container%s extends Container
|
||||
'deprecated_service' => __DIR__.'/getDeprecatedServiceService.php',
|
||||
'factory_service' => __DIR__.'/getFactoryServiceService.php',
|
||||
'factory_service_simple' => __DIR__.'/getFactoryServiceSimpleService.php',
|
||||
'factory_simple' => __DIR__.'/getFactorySimpleService.php',
|
||||
'foo' => __DIR__.'/getFooService.php',
|
||||
'foo.baz' => __DIR__.'/getFoo_BazService.php',
|
||||
'foo_with_inline' => __DIR__.'/getFooWithInlineService.php',
|
||||
@ -281,6 +293,9 @@ class Container%s extends Container
|
||||
'new_factory_service' => __DIR__.'/getNewFactoryServiceService.php',
|
||||
'service_from_static_method' => __DIR__.'/getServiceFromStaticMethodService.php',
|
||||
);
|
||||
$this->privates = array(
|
||||
'factory_simple' => true,
|
||||
);
|
||||
$this->aliases = array(
|
||||
'alias_for_alias' => 'foo',
|
||||
'alias_for_foo' => 'foo',
|
||||
|
@ -39,6 +39,7 @@ class ProjectServiceContainer extends Container
|
||||
'deprecated_service' => 'getDeprecatedServiceService',
|
||||
'factory_service' => 'getFactoryServiceService',
|
||||
'factory_service_simple' => 'getFactoryServiceSimpleService',
|
||||
'factory_simple' => 'getFactorySimpleService',
|
||||
'foo' => 'getFooService',
|
||||
'foo.baz' => 'getFoo_BazService',
|
||||
'foo_bar' => 'getFooBarService',
|
||||
@ -49,6 +50,9 @@ class ProjectServiceContainer extends Container
|
||||
'new_factory_service' => 'getNewFactoryServiceService',
|
||||
'service_from_static_method' => 'getServiceFromStaticMethodService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'factory_simple' => true,
|
||||
);
|
||||
$this->aliases = array(
|
||||
'alias_for_alias' => 'foo',
|
||||
'alias_for_foo' => 'foo',
|
||||
@ -89,7 +93,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getBarService()
|
||||
{
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
|
||||
$this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar'));
|
||||
|
||||
@ -107,7 +111,7 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$this->services['baz'] = $instance = new \Baz();
|
||||
|
||||
$instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->get('foo_with_inline')) && false ?: '_'});
|
||||
$instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->getFooWithInlineService()) && false ?: '_'});
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -120,7 +124,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getConfiguredServiceService()
|
||||
{
|
||||
$a = new \ConfClass();
|
||||
$a->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'});
|
||||
$a->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->getBazService()) && false ?: '_'});
|
||||
|
||||
$this->services['configured_service'] = $instance = new \stdClass();
|
||||
|
||||
@ -184,7 +188,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFactoryServiceService()
|
||||
{
|
||||
return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}->getInstance();
|
||||
return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'}->getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,7 +198,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFactoryServiceSimpleService()
|
||||
{
|
||||
return $this->services['factory_service_simple'] = (new \SimpleFactoryClass('foo'))->getInstance();
|
||||
return $this->services['factory_service_simple'] = ${($_ = isset($this->services['factory_simple']) ? $this->services['factory_simple'] : $this->getFactorySimpleService()) && false ?: '_'}->getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,14 +208,14 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFooService()
|
||||
{
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
$a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
|
||||
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
|
||||
|
||||
$instance->foo = 'bar';
|
||||
$instance->moo = $a;
|
||||
$instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
|
||||
$instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'});
|
||||
$instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->getBarService()) && false ?: '_'});
|
||||
$instance->initialize();
|
||||
sc_configure($instance);
|
||||
|
||||
@ -239,7 +243,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFooBarService()
|
||||
{
|
||||
return new \Bar\FooClass(${($_ = isset($this->services['deprecated_service']) ? $this->services['deprecated_service'] : $this->get('deprecated_service')) && false ?: '_'});
|
||||
return new \Bar\FooClass(${($_ = isset($this->services['deprecated_service']) ? $this->services['deprecated_service'] : $this->getDeprecatedServiceService()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,7 +258,7 @@ class ProjectServiceContainer extends Container
|
||||
$this->services['foo_with_inline'] = $instance = new \Foo();
|
||||
|
||||
$a->pub = 'pub';
|
||||
$a->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'});
|
||||
$a->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->getBazService()) && false ?: '_'});
|
||||
|
||||
$instance->setBar($a);
|
||||
|
||||
@ -269,7 +273,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getLazyContextService()
|
||||
{
|
||||
return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () {
|
||||
yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
yield 'k2' => $this;
|
||||
}, 2), new RewindableGenerator(function () {
|
||||
return new \EmptyIterator();
|
||||
@ -284,7 +288,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getLazyContextIgnoreInvalidRefService()
|
||||
{
|
||||
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
|
||||
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->getFoo_BazService()) && false ?: '_'};
|
||||
}, 1), new RewindableGenerator(function () {
|
||||
return new \EmptyIterator();
|
||||
}, 0));
|
||||
@ -301,9 +305,9 @@ class ProjectServiceContainer extends Container
|
||||
|
||||
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
||||
|
||||
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'});
|
||||
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'});
|
||||
$instance->setBar(NULL);
|
||||
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
||||
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -335,6 +339,20 @@ class ProjectServiceContainer extends Container
|
||||
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the private 'factory_simple' shared service.
|
||||
*
|
||||
* @return \SimpleFactoryClass
|
||||
*
|
||||
* @deprecated The "factory_simple" service is deprecated. You should stop using it, as it will soon be removed.
|
||||
*/
|
||||
protected function getFactorySimpleService()
|
||||
{
|
||||
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->services['factory_simple'] = new \SimpleFactoryClass('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -78,7 +78,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getBarServiceService()
|
||||
{
|
||||
return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'});
|
||||
return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->services['baz_service'] = new \stdClass()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,9 +89,9 @@ class ProjectServiceContainer extends Container
|
||||
protected function getFooServiceService()
|
||||
{
|
||||
return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\ServiceLocator(array('bar' => function () {
|
||||
return ${($_ = isset($this->services['bar_service']) ? $this->services['bar_service'] : $this->get('bar_service')) && false ?: '_'};
|
||||
return ${($_ = isset($this->services['bar_service']) ? $this->services['bar_service'] : $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->services['baz_service'] = new \stdClass()) && false ?: '_'})) && false ?: '_'};
|
||||
}, 'baz' => function () {
|
||||
$f = function (\stdClass $v) { return $v; }; return $f(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'});
|
||||
$f = function (\stdClass $v) { return $v; }; return $f(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->services['baz_service'] = new \stdClass()) && false ?: '_'});
|
||||
}, 'nil' => function () {
|
||||
return NULL;
|
||||
}));
|
||||
@ -135,7 +135,7 @@ class ProjectServiceContainer extends Container
|
||||
protected function getTranslator1Service()
|
||||
{
|
||||
return $this->services['translator_1'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_1' => function () {
|
||||
return ${($_ = isset($this->services['translator.loader_1']) ? $this->services['translator.loader_1'] : $this->get('translator.loader_1')) && false ?: '_'};
|
||||
return ${($_ = isset($this->services['translator.loader_1']) ? $this->services['translator.loader_1'] : $this->services['translator.loader_1'] = new \stdClass()) && false ?: '_'};
|
||||
})));
|
||||
}
|
||||
|
||||
@ -147,10 +147,10 @@ class ProjectServiceContainer extends Container
|
||||
protected function getTranslator2Service()
|
||||
{
|
||||
$this->services['translator_2'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_2' => function () {
|
||||
return ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->get('translator.loader_2')) && false ?: '_'};
|
||||
return ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->services['translator.loader_2'] = new \stdClass()) && false ?: '_'};
|
||||
})));
|
||||
|
||||
$instance->addResource('db', ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->get('translator.loader_2')) && false ?: '_'}, 'nl');
|
||||
$instance->addResource('db', ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->services['translator.loader_2'] = new \stdClass()) && false ?: '_'}, 'nl');
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -162,10 +162,10 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getTranslator3Service()
|
||||
{
|
||||
$a = ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->get('translator.loader_3')) && false ?: '_'};
|
||||
$a = ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->services['translator.loader_3'] = new \stdClass()) && false ?: '_'};
|
||||
|
||||
$this->services['translator_3'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_3' => function () {
|
||||
return ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->get('translator.loader_3')) && false ?: '_'};
|
||||
return ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->services['translator.loader_3'] = new \stdClass()) && false ?: '_'};
|
||||
})));
|
||||
|
||||
$instance->addResource('db', $a, 'nl');
|
||||
|
@ -72,7 +72,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getBarServiceService()
|
||||
{
|
||||
return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'});
|
||||
return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->services['baz_service'] = new \stdClass()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getFooServiceService()
|
||||
{
|
||||
return $this->services['foo_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'});
|
||||
return $this->services['foo_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->services['baz_service'] = new \stdClass()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getPublicFooService()
|
||||
{
|
||||
return $this->services['public_foo'] = new \stdClass(${($_ = isset($this->services['private_foo']) ? $this->services['private_foo'] : $this->getPrivateFooService()) && false ?: '_'});
|
||||
return $this->services['public_foo'] = new \stdClass(${($_ = isset($this->services['private_foo']) ? $this->services['private_foo'] : $this->services['private_foo'] = new \stdClass()) && false ?: '_'});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,13 +87,13 @@ class ProjectServiceContainer extends Container
|
||||
protected function getFooServiceService()
|
||||
{
|
||||
return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber(new \Symfony\Component\DependencyInjection\ServiceLocator(array('Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => function () {
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v = null) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->getCustomDefinitionService()) && false ?: '_'});
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v = null) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition()) && false ?: '_'});
|
||||
}, 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => function () {
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')) && false ?: '_'});
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber()) && false ?: '_'});
|
||||
}, 'bar' => function () {
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')) && false ?: '_'});
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber()) && false ?: '_'});
|
||||
}, 'baz' => function () {
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v = null) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->getCustomDefinitionService()) && false ?: '_'});
|
||||
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v = null) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition()) && false ?: '_'});
|
||||
})));
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,12 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
$this->services['bar'] = $instance = new \stdClass();
|
||||
|
||||
$instance->foo1 = ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
$instance->foo2 = null;
|
||||
$instance->foo2 = ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
$instance->foo3 = ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
$instance->closures = array(0 => function () {
|
||||
return ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
}, 1 => function () {
|
||||
return null;
|
||||
return ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
}, 2 => function () {
|
||||
return ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
});
|
||||
@ -90,7 +90,7 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
yield 'foo1' => ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
}
|
||||
if (false) {
|
||||
yield 'foo2' => null;
|
||||
yield 'foo2' => ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
}
|
||||
if (isset($this->services['foo3'])) {
|
||||
yield 'foo3' => ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
@ -111,7 +111,7 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
{
|
||||
$this->services['baz'] = $instance = new \stdClass();
|
||||
|
||||
$instance->foo3 = ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : $this->getFoo3Service()) && false ?: '_'};
|
||||
$instance->foo3 = ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : $this->services['foo3'] = new \stdClass()) && false ?: '_'};
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
@ -114,6 +114,7 @@
|
||||
</service>
|
||||
<service id="factory_simple" class="SimpleFactoryClass" public="false">
|
||||
<argument>foo</argument>
|
||||
<deprecated>The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.</deprecated>
|
||||
</service>
|
||||
<service id="factory_service_simple" class="Bar">
|
||||
<factory service="factory_simple" method="getInstance"/>
|
||||
|
@ -106,6 +106,7 @@ services:
|
||||
factory: [Bar\FooClass, getInstance]
|
||||
factory_simple:
|
||||
class: SimpleFactoryClass
|
||||
deprecated: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.
|
||||
public: false
|
||||
arguments: ['foo']
|
||||
factory_service_simple:
|
||||
|
Reference in New Issue
Block a user