diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index 73c2a0605c061..84e0d35db8c16 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -142,6 +142,10 @@ public function registerContainerConfiguration(LoaderInterface $loader) } $container->setAlias(static::class, 'kernel')->setPublic(true); + + if (!$container->hasParameter('container.dumper.inline_factories')) { + $container->setParameter('container.dumper.inline_factories', false); + } }); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index abba94468becd..469effd9747a3 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -68,7 +68,7 @@ class PhpDumper extends Dumper private $variableCount; private $inlinedDefinitions; private $serviceCalls; - private $reservedVariables = ['instance', 'class', 'this']; + private $reservedVariables = ['instance', 'class', 'this', 'container']; private $expressionLanguage; private $targetDirRegex; private $targetDirMaxMatches; @@ -246,20 +246,24 @@ public function dump(array $options = []) if ($this->addGetService) { $code = preg_replace( "/(\r?\n\r?\n public function __construct.+?\\{\r?\n)/s", - "\n private \$getService;$1 \$this->getService = \\Closure::fromCallable([\$this, 'getService']);\n", + "\n protected \$getService;$1 \$this->getService = \\Closure::fromCallable([\$this, 'getService']);\n", $code, 1 ); } if ($this->asFiles) { - $fileStart = <<docStar} + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class %s extends {$options['class']} +{%s} EOF; $files = []; @@ -281,7 +285,7 @@ public function dump(array $options = []) if (!$this->inlineFactories) { foreach ($this->generateServiceFiles($services) as $file => $c) { - $files[$file] = $fileStart.$c; + $files[$file] = sprintf($fileTemplate, substr($file, 0, -4), $c); } foreach ($proxyClasses as $file => $c) { $files[$file] = " $c) { - $code["Container{$hash}/{$file}"] = $c; + $code["Container{$hash}/{$file}"] = substr_replace($c, "namespace ? "\nnamespace {$this->namespace};\n" : ''; $time = $options['build_time']; $id = hash('crc32', $hash.$time); @@ -313,6 +315,9 @@ public function dump(array $options = []) if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) { $autoloadFile = substr($this->export($autoloadFile), 2, -1); + $factoryFiles = array_reverse(array_keys($code)); + $factoryFiles = implode("';\nrequire __DIR__.'/", $factoryFiles); + $code[$options['class'].'.preload.php'] = <<inlineRequires ? substr($proxyCode, \strlen($code)) : $proxyCode, 3)[1])] = $proxyCode; + $proxyClass = explode(' ', $this->inlineRequires ? substr($proxyCode, \strlen($code)) : $proxyCode, 3)[1]; + + if ($this->asFiles || $this->namespace) { + $proxyCode .= "\n\\class_alias(__NAMESPACE__.'\\\\$proxyClass', '$proxyClass', false);\n"; + } + + $proxyClasses[$proxyClass.'.php'] = $proxyCode; } return $proxyClasses; @@ -784,34 +795,35 @@ private function addService(string $id, Definition $definition): array $shared = $definition->isShared() ? ' shared' : ''; $public = $definition->isPublic() ? 'public' : 'private'; $autowired = $definition->isAutowired() ? ' autowired' : ''; + $asFile = $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition); + $methodName = $this->generateMethodName($id); - if ($definition->isLazy()) { + if ($asFile || $definition->isLazy()) { $lazyInitialization = '$lazyLoad = true'; } else { $lazyInitialization = ''; } - $asFile = $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition); - $methodName = $this->generateMethodName($id); - if ($asFile) { - $file = $methodName.'.php'; - $code = " // Returns the $public '$id'$shared$autowired service.\n\n"; - } else { - $file = null; - $code = <<docStar} * Gets the $public '$id'$shared$autowired service. * * $return EOF; - $code = str_replace('*/', ' ', $code).<<hasErrors() && $e = $definition->getErrors()) { @@ -833,8 +845,8 @@ protected function {$methodName}($lazyInitialization) } if ($this->getProxyDumper()->isProxyCandidate($definition)) { - $factoryCode = $asFile ? ($definition->isShared() ? "\$this->load('%s.php', false)" : '$this->factories[%2$s](false)') : '$this->%s(false)'; - $code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName, $this->doExport($id))); + $factoryCode = $asFile ? "\$this->load('%s', false)" : '$this->%s(false)'; + $code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName)); } $code .= $this->addServiceInclude($id, $definition); @@ -842,11 +854,12 @@ protected function {$methodName}($lazyInitialization) } if ($asFile) { - $code = implode("\n", array_map(function ($line) { return $line ? substr($line, 8) : $line; }, explode("\n", $code))); - } else { - $code .= " }\n"; + $code = str_replace('$this', '$container', $code); + $code = str_replace('function () {', 'function () use ($container) {', $code); } + $code .= " }\n"; + $this->definitionVariables = $this->inlinedDefinitions = null; $this->referenceVariables = $this->serviceCalls = null; @@ -1017,21 +1030,6 @@ private function generateServiceFiles(array $services): iterable ksort($definitions); foreach ($definitions as $id => $definition) { if ((list($file, $code) = $services[$id]) && null !== $file && ($definition->isPublic() || !$this->isTrivialInstance($definition) || isset($this->locatedIds[$id]))) { - if (!$definition->isShared()) { - $i = strpos($code, "\n\ninclude_once "); - if (false !== $i && false !== $i = strpos($code, "\n\n", 2 + $i)) { - $code = [substr($code, 0, 2 + $i), substr($code, 2 + $i)]; - } else { - $code = ["\n", $code]; - } - $code[1] = implode("\n", array_map(function ($line) { return $line ? ' '.$line : $line; }, explode("\n", $code[1]))); - $factory = sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id)); - $lazyloadInitialization = $definition->isLazy() ? '$lazyLoad = true' : ''; - - $code[1] = sprintf("%s = function (%s) {\n%s};\n\nreturn %1\$s();\n", $factory, $lazyloadInitialization, $code[1]); - $code = $code[0].$code[1]; - } - yield $file => $code; } } @@ -1112,27 +1110,24 @@ private function startClass(string $class, string $baseClass): string use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /*{$this->docStar} - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class $class extends $baseClass { - private \$parameters = []; + protected \$parameters = []; public function __construct() { EOF; if ($this->asFiles) { - $code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code); + $code = str_replace('$parameters = []', "\$containerDir;\n protected \$parameters = [];\n private \$buildParameters", $code); $code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code); $code .= " \$this->buildParameters = \$buildParameters;\n"; $code .= " \$this->containerDir = \$containerDir;\n"; if (null !== $this->targetDirRegex) { - $code = str_replace('$parameters', "\$targetDir;\n private \$parameters", $code); + $code = str_replace('$parameters = []', "\$targetDir;\n protected \$parameters = []", $code); $code .= ' $this->targetDir = \\dirname($containerDir);'."\n"; } } @@ -1176,11 +1171,23 @@ public function isCompiled(): bool $code .= $this->addRemovedIds(); if ($this->asFiles && !$this->inlineFactories) { - $code .= <<containerDir.\\DIRECTORY_SEPARATOR.\$file; + if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) { + return $class::do($this, $lazyLoad); + } + + if ('.' === $file[-4]) { + $class = substr($class, 0, -4); + } else { + $file .= '.php'; + } + + $service = require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + + return class_exists($class, false) ? $class::do($this, $lazyLoad) : $service; } EOF; @@ -1191,16 +1198,13 @@ protected function load(\$file, \$lazyLoad = true) if (!$proxyDumper->isProxyCandidate($definition)) { continue; } + if ($this->asFiles && !$this->inlineFactories) { - $proxyLoader = '$this->load("{$class}.php")'; - } elseif ($this->namespace || $this->inlineFactories) { - $proxyLoader = 'class_alias(__NAMESPACE__."\\\\$class", $class, false)'; + $proxyLoader = "class_exists(\$class, false) || require __DIR__.'/'.\$class.'.php';\n\n "; } else { $proxyLoader = ''; } - if ($proxyLoader) { - $proxyLoader = "class_exists(\$class, false) || {$proxyLoader};\n\n "; - } + $code .= << $definition) { if (!$definition->isSynthetic() && $definition->isPublic() && !$this->isHotPath($definition)) { - $code .= sprintf(" %s => '%s.php',\n", $this->doExport($id), $this->generateMethodName($id)); + $code .= sprintf(" %s => '%s',\n", $this->doExport($id), $this->generateMethodName($id)); } } @@ -1709,7 +1713,7 @@ private function dumpValue($value, bool $interpolate = true): string $this->export($k), $this->export($definition->isShared() ? ($definition->isPublic() ? 'services' : 'privates') : false), $this->doExport($id), - $this->export(ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $v->getInvalidBehavior() && !\is_string($load) ? $this->generateMethodName($id).($load ? '.php' : '') : null), + $this->export(ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $v->getInvalidBehavior() && !\is_string($load) ? $this->generateMethodName($id) : null), $this->export($load) ); $serviceTypes .= sprintf("\n %s => %s,", $this->export($k), $this->export($v instanceof TypedReference ? $v->getType() : '?')); @@ -1850,11 +1854,7 @@ private function getServiceCall(string $id, Reference $reference = null): string } $code = "($code)"; } elseif ($this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition)) { - $code = sprintf("\$this->load('%s.php')", $this->generateMethodName($id)); - if (!$definition->isShared()) { - $factory = sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id)); - $code = sprintf('(isset(%s) ? %1$s() : %s)', $factory, $code); - } + $code = sprintf("\$this->load('%s')", $this->generateMethodName($id)); } else { $code = sprintf('$this->%s()', $this->generateMethodName($id)); } @@ -2045,6 +2045,14 @@ private function doExport($value, bool $resolveEnv = false) } else { $export = var_export($value, true); } + if ($this->asFiles) { + if (false !== strpos($export, '$this')) { + $export = str_replace('$this', "$'.'this", $export); + } + if (false !== strpos($export, 'function () {')) { + $export = str_replace('function () {', "function ('.') {", $export); + } + } if ($resolveEnv && "'" === $export[0] && $export !== $resolvedExport = $this->container->resolveEnvPlaceholders($export, "'.\$this->getEnv('string:%s').'")) { $export = $resolvedExport; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php index a7cf90e1a57b1..65fa0808d3eef 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php index 33d30ef9db649..cec79725f7319 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php @@ -12,14 +12,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php index 197e4c99f01e6..31ac1d32b82bd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php @@ -12,14 +12,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php index c56f8d7048383..f64250f7b1e7f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php @@ -12,14 +12,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php index 464b75a5976ee..32c6ffda4b562 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php @@ -12,14 +12,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index a3b402c1e749f..6cd3102ce9ff1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -12,14 +12,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index 29d01cf81de56..4ec13c2b832e3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index d54782c7c6b3a..3a3cb149914ca 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index ffab1abb1deba..1fec4f85b2dc0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index 2622869080b3b..a99a61733bd7f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 2c74240ac36d0..9c0d437a70b8a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index c7e8ba70720b1..0c2a5b38abfe3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 29b3627def9c6..9359ad506e01c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index e872e4818a551..145b7db457a30 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index d4dae984b68e2..a1f2b09a5573a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -10,14 +10,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { - private $parameters = []; + protected $parameters = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 47d6594970159..5a9af100b772c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -2,6 +2,8 @@ Array ( [Container%s/removed-ids.php] => true, 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, @@ -19,337 +21,657 @@ return [ [Container%s/getBAR2Service.php] => services['BAR'] = $instance = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getBAR2Service extends ProjectServiceContainer +{ + /** + * Gets the public 'BAR' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + $container->services['BAR'] = $instance = new \stdClass(); -$instance->bar = ($this->services['bar'] ?? $this->getBarService()); + $instance->bar = ($container->services['bar'] ?? $container->getBarService()); -return $instance; + return $instance; + } +} [Container%s/getBAR22Service.php] => services['BAR2'] = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getBAR22Service extends ProjectServiceContainer +{ + /** + * Gets the public 'BAR2' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['BAR2'] = new \stdClass(); + } +} [Container%s/getBar23Service.php] => services['bar2'] = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getBar23Service extends ProjectServiceContainer +{ + /** + * Gets the public 'bar2' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['bar2'] = new \stdClass(); + } +} [Container%s/getBazService.php] => services['baz'] = $instance = new \Baz(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getBazService extends ProjectServiceContainer +{ + /** + * Gets the public 'baz' shared service. + * + * @return \Baz + */ + public static function do($container, $lazyLoad = true) + { + $container->services['baz'] = $instance = new \Baz(); -$instance->setFoo(($this->services['foo_with_inline'] ?? $this->load('getFooWithInlineService.php'))); + $instance->setFoo(($container->services['foo_with_inline'] ?? $container->load('getFooWithInlineService'))); -return $instance; + return $instance; + } +} [Container%s/getConfiguredServiceService.php] => services['configured_service'] = $instance = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getConfiguredServiceService extends ProjectServiceContainer +{ + /** + * Gets the public 'configured_service' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + $container->services['configured_service'] = $instance = new \stdClass(); -$a = new \ConfClass(); -$a->setFoo(($this->services['baz'] ?? $this->load('getBazService.php'))); + $a = new \ConfClass(); + $a->setFoo(($container->services['baz'] ?? $container->load('getBazService'))); -$a->configureStdClass($instance); + $a->configureStdClass($instance); -return $instance; + return $instance; + } +} [Container%s/getConfiguredServiceSimpleService.php] => services['configured_service_simple'] = $instance = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getConfiguredServiceSimpleService extends ProjectServiceContainer +{ + /** + * Gets the public 'configured_service_simple' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + $container->services['configured_service_simple'] = $instance = new \stdClass(); -(new \ConfClass('bar'))->configureStdClass($instance); + (new \ConfClass('bar'))->configureStdClass($instance); -return $instance; + return $instance; + } +} [Container%s/getDecoratorServiceService.php] => services['decorator_service'] = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getDecoratorServiceService extends ProjectServiceContainer +{ + /** + * Gets the public 'decorator_service' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['decorator_service'] = new \stdClass(); + } +} [Container%s/getDecoratorServiceWithNameService.php] => services['decorator_service_with_name'] = new \stdClass(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getDecoratorServiceWithNameService extends ProjectServiceContainer +{ + /** + * Gets the public 'decorator_service_with_name' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['decorator_service_with_name'] = new \stdClass(); + } +} [Container%s/getDeprecatedServiceService.php] => services['deprecated_service'] = new \stdClass(); + return $container->services['deprecated_service'] = new \stdClass(); + } +} [Container%s/getFactoryServiceService.php] => services['factory_service'] = ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php'))->getInstance(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFactoryServiceService extends ProjectServiceContainer +{ + /** + * Gets the public 'factory_service' shared service. + * + * @return \Bar + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['factory_service'] = ($container->services['foo.baz'] ?? $container->load('getFoo_BazService'))->getInstance(); + } +} [Container%s/getFactoryServiceSimpleService.php] => services['factory_service_simple'] = $this->load('getFactorySimpleService.php')->getInstance(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFactoryServiceSimpleService extends ProjectServiceContainer +{ + /** + * Gets the public 'factory_service_simple' shared service. + * + * @return \Bar + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['factory_service_simple'] = $container->load('getFactorySimpleService')->getInstance(); + } +} [Container%s/getFactorySimpleService.php] => services['foo.baz'] ?? $this->load('getFoo_BazService.php')); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFooService extends ProjectServiceContainer +{ + /** + * Gets the public 'foo' shared service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + $a = ($container->services['foo.baz'] ?? $container->load('getFoo_BazService')); -$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, ['bar' => 'foo is bar', 'foobar' => 'bar'], true, $this); + $container->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, ['bar' => 'foo is bar', 'foobar' => 'bar'], true, $container); -$instance->foo = 'bar'; -$instance->moo = $a; -$instance->qux = ['bar' => 'foo is bar', 'foobar' => 'bar']; -$instance->setBar(($this->services['bar'] ?? $this->getBarService())); -$instance->initialize(); -sc_configure($instance); + $instance->foo = 'bar'; + $instance->moo = $a; + $instance->qux = ['bar' => 'foo is bar', 'foobar' => 'bar']; + $instance->setBar(($container->services['bar'] ?? $container->getBarService())); + $instance->initialize(); + sc_configure($instance); -return $instance; + return $instance; + } +} [Container%s/getFoo_BazService.php] => services['foo.baz'] = $instance = \BazClass::getInstance(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFoo_BazService extends ProjectServiceContainer +{ + /** + * Gets the public 'foo.baz' shared service. + * + * @return \BazClass + */ + public static function do($container, $lazyLoad = true) + { + $container->services['foo.baz'] = $instance = \BazClass::getInstance(); -\BazClass::configureStatic1($instance); + \BazClass::configureStatic1($instance); -return $instance; + return $instance; + } +} [Container%s/getFooBarService.php] => factories['foo_bar'] = function () { - // Returns the public 'foo_bar' service. - - return new \Bar\FooClass(($this->services['deprecated_service'] ?? $this->load('getDeprecatedServiceService.php'))); -}; - -return $this->factories['foo_bar'](); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFooBarService extends ProjectServiceContainer +{ + /** + * Gets the public 'foo_bar' service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + return new \Bar\FooClass(($container->services['deprecated_service'] ?? $container->load('getDeprecatedServiceService'))); + } +} [Container%s/getFooWithInlineService.php] => services['foo_with_inline'] = $instance = new \Foo(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getFooWithInlineService extends ProjectServiceContainer +{ + /** + * Gets the public 'foo_with_inline' shared service. + * + * @return \Foo + */ + public static function do($container, $lazyLoad = true) + { + $container->services['foo_with_inline'] = $instance = new \Foo(); -$a = new \Bar(); -$a->pub = 'pub'; -$a->setBaz(($this->services['baz'] ?? $this->load('getBazService.php'))); + $a = new \Bar(); + $a->pub = 'pub'; + $a->setBaz(($container->services['baz'] ?? $container->load('getBazService'))); -$instance->setBar($a); + $instance->setBar($a); -return $instance; + return $instance; + } +} [Container%s/getLazyContextService.php] => services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () { - yield 'k1' => ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php')); - yield 'k2' => $this; -}, 2), new RewindableGenerator(function () { - return new \EmptyIterator(); -}, 0)); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getLazyContextService extends ProjectServiceContainer +{ + /** + * Gets the public 'lazy_context' shared service. + * + * @return \LazyContext + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($container) { + yield 'k1' => ($container->services['foo.baz'] ?? $container->load('getFoo_BazService')); + yield 'k2' => $container; + }, 2), new RewindableGenerator(function () use ($container) { + return new \EmptyIterator(); + }, 0)); + } +} [Container%s/getLazyContextIgnoreInvalidRefService.php] => services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () { - yield 0 => ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php')); -}, 1), new RewindableGenerator(function () { - return new \EmptyIterator(); -}, 0)); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getLazyContextIgnoreInvalidRefService extends ProjectServiceContainer +{ + /** + * Gets the public 'lazy_context_ignore_invalid_ref' shared service. + * + * @return \LazyContext + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($container) { + yield 0 => ($container->services['foo.baz'] ?? $container->load('getFoo_BazService')); + }, 1), new RewindableGenerator(function () use ($container) { + return new \EmptyIterator(); + }, 0)); + } +} [Container%s/getMethodCall1Service.php] => targetDir.''.'/Fixtures/includes/foo.php'; +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getMethodCall1Service extends ProjectServiceContainer +{ + /** + * Gets the public 'method_call1' shared service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + include_once $container->targetDir.''.'/Fixtures/includes/foo.php'; -$this->services['method_call1'] = $instance = new \Bar\FooClass(); + $container->services['method_call1'] = $instance = new \Bar\FooClass(); -$instance->setBar(($this->services['foo'] ?? $this->load('getFooService.php'))); -$instance->setBar(NULL); -$instance->setBar((($this->services['foo'] ?? $this->load('getFooService.php'))->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default")))); + $instance->setBar(($container->services['foo'] ?? $container->load('getFooService'))); + $instance->setBar(NULL); + $instance->setBar((($container->services['foo'] ?? $container->load('getFooService'))->foo() . (($container->hasParameter("foo")) ? ($container->getParameter("foo")) : ("default")))); -return $instance; + return $instance; + } +} [Container%s/getNewFactoryServiceService.php] => foo = 'bar'; +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getNewFactoryServiceService extends ProjectServiceContainer +{ + /** + * Gets the public 'new_factory_service' shared service. + * + * @return \FooBarBaz + */ + public static function do($container, $lazyLoad = true) + { + $a = new \FactoryClass(); + $a->foo = 'bar'; -$this->services['new_factory_service'] = $instance = $a->getInstance(); + $container->services['new_factory_service'] = $instance = $a->getInstance(); -$instance->foo = 'bar'; + $instance->foo = 'bar'; -return $instance; + return $instance; + } +} [Container%s/getNonSharedFooService.php] => targetDir.''.'/Fixtures/includes/foo.php'; - -$this->factories['non_shared_foo'] = function () { - return new \Bar\FooClass(); -}; +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getNonSharedFooService extends ProjectServiceContainer +{ + /** + * Gets the public 'non_shared_foo' service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + include_once $container->targetDir.''.'/Fixtures/includes/foo.php'; -return $this->factories['non_shared_foo'](); + return new \Bar\FooClass(); + } +} [Container%s/getRuntimeErrorService.php] => services['runtime_error'] = new \stdClass($this->throw('Service "errored_definition" is broken.')); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getRuntimeErrorService extends ProjectServiceContainer +{ + /** + * Gets the public 'runtime_error' shared service. + * + * @return \stdClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['runtime_error'] = new \stdClass($container->throw('Service "errored_definition" is broken.')); + } +} [Container%s/getServiceFromStaticMethodService.php] => services['service_from_static_method'] = \Bar\FooClass::getInstance(); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getServiceFromStaticMethodService extends ProjectServiceContainer +{ + /** + * Gets the public 'service_from_static_method' shared service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['service_from_static_method'] = \Bar\FooClass::getInstance(); + } +} [Container%s/getTaggedIteratorService.php] => services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () { - yield 0 => ($this->services['foo'] ?? $this->load('getFooService.php')); - yield 1 => ($this->privates['tagged_iterator_foo'] ?? ($this->privates['tagged_iterator_foo'] = new \Bar())); -}, 2)); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getTaggedIteratorService extends ProjectServiceContainer +{ + /** + * Gets the public 'tagged_iterator' shared service. + * + * @return \Bar + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($container) { + yield 0 => ($container->services['foo'] ?? $container->load('getFooService')); + yield 1 => ($container->privates['tagged_iterator_foo'] ?? ($container->privates['tagged_iterator_foo'] = new \Bar())); + }, 2)); + } +} [Container%s/getThrowingOneService.php] => services['throwing_one'] = new \Bar\FooClass($this->throw('No-no-no-no')); +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getThrowingOneService extends ProjectServiceContainer +{ + /** + * Gets the public 'throwing_one' shared service. + * + * @return \Bar\FooClass + */ + public static function do($container, $lazyLoad = true) + { + return $container->services['throwing_one'] = new \Bar\FooClass($container->throw('No-no-no-no')); + } +} [Container%s/ProjectServiceContainer.php] => 'getBarService', ]; $this->fileMap = [ - 'BAR' => 'getBAR2Service.php', - 'BAR2' => 'getBAR22Service.php', - 'bar2' => 'getBar23Service.php', - 'baz' => 'getBazService.php', - 'configured_service' => 'getConfiguredServiceService.php', - 'configured_service_simple' => 'getConfiguredServiceSimpleService.php', - 'decorator_service' => 'getDecoratorServiceService.php', - 'decorator_service_with_name' => 'getDecoratorServiceWithNameService.php', - 'deprecated_service' => 'getDeprecatedServiceService.php', - 'factory_service' => 'getFactoryServiceService.php', - 'factory_service_simple' => 'getFactoryServiceSimpleService.php', - 'foo' => 'getFooService.php', - 'foo.baz' => 'getFoo_BazService.php', - 'foo_bar' => 'getFooBarService.php', - 'foo_with_inline' => 'getFooWithInlineService.php', - 'lazy_context' => 'getLazyContextService.php', - 'lazy_context_ignore_invalid_ref' => 'getLazyContextIgnoreInvalidRefService.php', - 'method_call1' => 'getMethodCall1Service.php', - 'new_factory_service' => 'getNewFactoryServiceService.php', - 'non_shared_foo' => 'getNonSharedFooService.php', - 'runtime_error' => 'getRuntimeErrorService.php', - 'service_from_static_method' => 'getServiceFromStaticMethodService.php', - 'tagged_iterator' => 'getTaggedIteratorService.php', - 'throwing_one' => 'getThrowingOneService.php', + 'BAR' => 'getBAR2Service', + 'BAR2' => 'getBAR22Service', + 'bar2' => 'getBar23Service', + 'baz' => 'getBazService', + 'configured_service' => 'getConfiguredServiceService', + 'configured_service_simple' => 'getConfiguredServiceSimpleService', + 'decorator_service' => 'getDecoratorServiceService', + 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', + 'deprecated_service' => 'getDeprecatedServiceService', + 'factory_service' => 'getFactoryServiceService', + 'factory_service_simple' => 'getFactoryServiceSimpleService', + 'foo' => 'getFooService', + 'foo.baz' => 'getFoo_BazService', + 'foo_bar' => 'getFooBarService', + 'foo_with_inline' => 'getFooWithInlineService', + 'lazy_context' => 'getLazyContextService', + 'lazy_context_ignore_invalid_ref' => 'getLazyContextIgnoreInvalidRefService', + 'method_call1' => 'getMethodCall1Service', + 'new_factory_service' => 'getNewFactoryServiceService', + 'non_shared_foo' => 'getNonSharedFooService', + 'runtime_error' => 'getRuntimeErrorService', + 'service_from_static_method' => 'getServiceFromStaticMethodService', + 'tagged_iterator' => 'getTaggedIteratorService', + 'throwing_one' => 'getThrowingOneService', ]; $this->aliases = [ 'alias_for_alias' => 'foo', @@ -441,7 +760,19 @@ class ProjectServiceContainer extends Container protected function load($file, $lazyLoad = true) { - return require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) { + return $class::do($this, $lazyLoad); + } + + if ('.' === $file[-4]) { + $class = substr($class, 0, -4); + } else { + $file .= '.php'; + } + + $service = require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + + return class_exists($class, false) ? $class::do($this, $lazyLoad) : $service; } /** @@ -451,7 +782,7 @@ class ProjectServiceContainer extends Container */ protected function getBarService() { - $a = ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php')); + $a = ($this->services['foo.baz'] ?? $this->load('getFoo_BazService')); $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar')); @@ -530,7 +861,40 @@ class ProjectServiceContainer extends Container } [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +require dirname(__DIR__, %d).'%svendor/autoload.php'; +require __DIR__.'/Container%s/ProjectServiceContainer.php'; +require __DIR__.'/Container%s/getThrowingOneService.php'; +require __DIR__.'/Container%s/getTaggedIteratorService.php'; +require __DIR__.'/Container%s/getServiceFromStaticMethodService.php'; +require __DIR__.'/Container%s/getRuntimeErrorService.php'; +require __DIR__.'/Container%s/getNonSharedFooService.php'; +require __DIR__.'/Container%s/getNewFactoryServiceService.php'; +require __DIR__.'/Container%s/getMethodCall1Service.php'; +require __DIR__.'/Container%s/getLazyContextIgnoreInvalidRefService.php'; +require __DIR__.'/Container%s/getLazyContextService.php'; +require __DIR__.'/Container%s/getFooWithInlineService.php'; +require __DIR__.'/Container%s/getFooBarService.php'; +require __DIR__.'/Container%s/getFoo_BazService.php'; +require __DIR__.'/Container%s/getFooService.php'; +require __DIR__.'/Container%s/getFactorySimpleService.php'; +require __DIR__.'/Container%s/getFactoryServiceSimpleService.php'; +require __DIR__.'/Container%s/getFactoryServiceService.php'; +require __DIR__.'/Container%s/getDeprecatedServiceService.php'; +require __DIR__.'/Container%s/getDecoratorServiceWithNameService.php'; +require __DIR__.'/Container%s/getDecoratorServiceService.php'; +require __DIR__.'/Container%s/getConfiguredServiceSimpleService.php'; +require __DIR__.'/Container%s/getConfiguredServiceService.php'; +require __DIR__.'/Container%s/getBazService.php'; +require __DIR__.'/Container%s/getBar23Service.php'; +require __DIR__.'/Container%s/getBAR22Service.php'; +require __DIR__.'/Container%s/getBAR2Service.php'; +require __DIR__.'/Container%s/removed-ids.php'; $classes = []; $classes[] = 'Bar\FooClass'; @@ -545,7 +909,7 @@ $classes[] = 'FactoryClass'; $classes[] = 'Request'; $classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; -%A +Preloader::preload($classes); [ProjectServiceContainer.php] => true, 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, @@ -31,17 +33,14 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { + protected $containerDir; + protected $targetDir; + protected $parameters = []; private $buildParameters; - private $containerDir; - private $targetDir; - private $parameters = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { @@ -530,7 +529,15 @@ class ProjectServiceContainer extends Container } [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +require dirname(__DIR__, %d).'%svendor/autoload.php'; +require __DIR__.'/Container%s/ProjectServiceContainer.php'; +require __DIR__.'/Container%s/removed-ids.php'; $classes = []; $classes[] = 'Bar\FooClass'; @@ -545,7 +552,7 @@ $classes[] = 'FactoryClass'; $classes[] = 'Request'; $classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; -%A +Preloader::preload($classes); [ProjectServiceContainer.php] => true, 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, @@ -21,17 +23,14 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; /** - * This class has been auto-generated - * by the Symfony Dependency Injection Component. - * - * @final + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class ProjectServiceContainer extends Container { + protected $containerDir; + protected $targetDir; + protected $parameters = []; private $buildParameters; - private $containerDir; - private $targetDir; - private $parameters = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { @@ -65,8 +64,6 @@ class ProjectServiceContainer extends Container protected function createProxy($class, \Closure $factory) { - class_exists($class, false) || class_alias(__NAMESPACE__."\\$class", $class, false); - return $factory(); } @@ -78,8 +75,8 @@ class ProjectServiceContainer extends Container protected function getLazyFooService($lazyLoad = true) { if ($lazyLoad) { - return $this->services['lazy_foo'] = $this->createProxy('FooClass_%s', function () { - return \FooClass_%s::staticProxyConstructor(function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { + return $this->services['lazy_foo'] = $this->createProxy('FooClass_8976cfa', function () { + return \FooClass_8976cfa::staticProxyConstructor(function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { $wrappedInstance = $this->getLazyFooService(false); $proxy->setProxyInitializer(null); @@ -163,15 +160,25 @@ class FooClass_%s extends \Bar\FooClass implements \ProxyManager\Proxy\VirtualPr %A } +\class_alias(__NAMESPACE__.'\\FooClass_%s', 'FooClass_%s', false); + [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +require dirname(__DIR__, %d).'%svendor/autoload.php'; +require __DIR__.'/Container%s/ProjectServiceContainer.php'; +require __DIR__.'/Container%s/removed-ids.php'; $classes = []; $classes[] = 'Bar\FooClass'; $classes[] = 'Bar\FooLazyClass'; $classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; -%A +Preloader::preload($classes); [ProjectServiceContainer.php] => true, 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, @@ -9,19 +11,28 @@ return [ [Container%s/getNonSharedFooService.php] => targetDir.''.'/Fixtures/includes/foo_lazy.php'; - -$this->factories['non_shared_foo'] = function ($lazyLoad = true) { - return new \Bar\FooLazyClass(); -}; +/** + * @internal This class has been auto-generated by the Symfony Dependency Injection Component. + */ +class getNonSharedFooService extends ProjectServiceContainer +{ + /** + * Gets the public 'non_shared_foo' service. + * + * @return \Bar\FooLazyClass + */ + public static function do($container, $lazyLoad = true) + { + include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php'; -return $this->factories['non_shared_foo'](); + return new \Bar\FooLazyClass(); + } +} [Container%s/ProjectServiceContainer.php] => targetDir = \dirname($containerDir); $this->services = $this->privates = []; $this->fileMap = [ - 'non_shared_foo' => 'getNonSharedFooService.php', + 'non_shared_foo' => 'getNonSharedFooService', ]; $this->aliases = []; @@ -79,18 +87,39 @@ class ProjectServiceContainer extends Container protected function load($file, $lazyLoad = true) { - return require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) { + return $class::do($this, $lazyLoad); + } + + if ('.' === $file[-4]) { + $class = substr($class, 0, -4); + } else { + $file .= '.php'; + } + + $service = require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + + return class_exists($class, false) ? $class::do($this, $lazyLoad) : $service; } } [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +require dirname(__DIR__, %d).'%svendor/autoload.php'; +require __DIR__.'/Container%s/ProjectServiceContainer.php'; +require __DIR__.'/Container%s/getNonSharedFooService.php'; +require __DIR__.'/Container%s/removed-ids.php'; $classes = []; $classes[] = 'Bar\FooLazyClass'; $classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; -%A +Preloader::preload($classes); [ProjectServiceContainer.php] => pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy