minor #33529 [DI] use dirname() when possible (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DI] use dirname() when possible

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

On second look, I think this works :)

Commits
-------

2eae300537 [DI] use dirname() when possible
This commit is contained in:
Nicolas Grekas 2019-09-10 15:08:12 +02:00
commit 541f80c635
48 changed files with 92 additions and 148 deletions

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\DependencyInjection\Dumper;
use Composer\Autoload\ClassLoader;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@ -36,6 +38,7 @@ use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator;
use Symfony\Component\DependencyInjection\TypedReference;
use Symfony\Component\DependencyInjection\Variable;
use Symfony\Component\ErrorHandler\DebugClassLoader;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpKernel\Kernel;
@ -296,8 +299,11 @@ EOF;
$namespaceLine = $this->namespace ? "\nnamespace {$this->namespace};\n" : '';
$time = $options['build_time'];
$id = hash('crc32', $hash.$time);
$this->asFiles = false;
if ($preload && null !== $autoloadFile = $this->getAutoloadFile()) {
$autoloadFile = substr($this->export($autoloadFile), 2, -1);
if ($preload) {
$code[$options['class'].'.preload.php'] = <<<EOF
<?php
@ -306,7 +312,7 @@ EOF;
use Symfony\Component\DependencyInjection\Dumper\Preloader;
require dirname(__DIR__, 3).'/vendor/autoload.php';
require $autoloadFile;
require __DIR__.'/Container{$hash}/{$options['class']}.php';
\$classes = [];
@ -511,7 +517,6 @@ EOF;
if ($this->inlineFactories) {
$this->inlinedRequires[$file] = true;
}
$file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file);
$code .= sprintf("include_once %s;\n", $file);
}
@ -553,7 +558,6 @@ EOF;
}
foreach (array_diff_key(array_flip($lineage), $this->inlinedRequires) as $file => $class) {
$file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file);
$code .= sprintf(" include_once %s;\n", $file);
}
}
@ -562,7 +566,6 @@ EOF;
if ($file = $def->getFile()) {
$file = $this->dumpValue($file);
$file = '(' === $file[0] ? substr($file, 1, -1) : $file;
$file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file);
$code .= sprintf(" include_once %s;\n", $file);
}
}
@ -1076,27 +1079,21 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class $class extends $baseClass
{
private \$parameters = [];
private \$targetDirs = [];
public function __construct()
{
EOF;
if (null !== $this->targetDirRegex) {
$dir = $this->asFiles ? '$this->targetDirs[0] = \\dirname($containerDir)' : '__DIR__';
$code .= <<<EOF
\$dir = {$dir};
for (\$i = 1; \$i <= {$this->targetDirMaxMatches}; ++\$i) {
\$this->targetDirs[\$i] = \$dir = \\dirname(\$dir);
}
EOF;
}
if ($this->asFiles) {
$code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $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 .= ' $this->targetDir = \\dirname($containerDir);'."\n";
}
}
if (Container::class !== $this->baseClass) {
@ -1350,12 +1347,11 @@ EOF;
foreach ($lineage as $file) {
if (!isset($this->inlinedRequires[$file])) {
$this->inlinedRequires[$file] = true;
$file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file);
$code .= sprintf("\n include_once %s;", $file);
}
}
return $code ? sprintf("\n \$this->privates['service_container'] = static function () {%s\n };\n", $code) : '';
return $code ? sprintf("\n \$this->privates['service_container'] = function () {%s\n };\n", $code) : '';
}
private function addDefaultParametersMethod(): string
@ -1374,7 +1370,7 @@ EOF;
$export = $this->exportParameters([$value]);
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) {
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $export[1])) {
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
} else {
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
@ -1776,7 +1772,7 @@ EOF;
return $dumpedValue;
}
if (!preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $dumpedValue)) {
if (!preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $dumpedValue)) {
return sprintf('$this->parameters[%s]', $this->doExport($name));
}
}
@ -1977,8 +1973,10 @@ EOF;
$dirname = $this->asFiles ? '$this->containerDir' : '__DIR__';
$offset = 1 + $this->targetDirMaxMatches - \count($matches);
if ($this->asFiles || 0 < $offset) {
$dirname = sprintf('$this->targetDirs[%d]', $offset);
if (0 < $offset) {
$dirname = sprintf('\dirname(__DIR__, %d)', $offset + (int) $this->asFiles);
} elseif ($this->asFiles) {
$dirname = "\$this->targetDir.''"; // empty string concatenation on purpose
}
if ($prefix || $suffix) {
@ -2027,4 +2025,37 @@ EOF;
return $export;
}
private function getAutoloadFile(): ?string
{
if (null === $this->targetDirRegex) {
return null;
}
foreach (spl_autoload_functions() as $autoloader) {
if (!\is_array($autoloader)) {
continue;
}
if ($autoloader[0] instanceof DebugClassLoader || $autoloader[0] instanceof LegacyDebugClassLoader) {
$autoloader = $autoloader[0]->getClassLoader();
}
if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) {
continue;
}
foreach (get_declared_classes() as $class) {
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
$file = (new \ReflectionClass($class))->getFileName();
if (preg_match($this->targetDirRegex.'A', $file)) {
return $file;
}
}
}
}
return null;
}
}

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{
$dir = __DIR__;
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -61,7 +56,7 @@ class ProjectServiceContainer extends Container
*/
protected function getTestService()
{
return $this->services['test'] = new \stdClass(('wiz'.$this->targetDirs[1]), [('wiz'.$this->targetDirs[1]) => ($this->targetDirs[2].'/')]);
return $this->services['test'] = new \stdClass(('wiz'.\dirname(__DIR__, 1)), [('wiz'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]);
}
public function getParameter($name)
@ -103,29 +98,21 @@ class ProjectServiceContainer extends Container
return $this->parameterBag;
}
private $loadedDynamicParameters = [
'foo' => false,
'buz' => false,
];
private $loadedDynamicParameters = [];
private $dynamicParameters = [];
private function getDynamicParameter(string $name)
{
switch ($name) {
case 'foo': $value = ('wiz'.$this->targetDirs[1]); break;
case 'buz': $value = $this->targetDirs[2]; break;
default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
$this->loadedDynamicParameters[$name] = true;
return $this->dynamicParameters[$name] = $value;
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
protected function getDefaultParameters(): array
{
return [
'foo' => ('wiz'.\dirname(__DIR__, 1)),
'bar' => __DIR__,
'baz' => (__DIR__.'/PhpDumperTest.php'),
'buz' => \dirname(__DIR__, 2),
];
}
}

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{
$dir = __DIR__;
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -119,7 +114,6 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
'baz' => false,
'json' => false,
'db_dsn' => false,
'env(json_file)' => false,
];
private $dynamicParameters = [];
@ -130,7 +124,6 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
case 'baz': $value = $this->getEnv('int:Baz'); break;
case 'json': $value = $this->getEnv('json:file:json_file'); break;
case 'db_dsn': $value = $this->getEnv('resolve:DB'); break;
case 'env(json_file)': $value = ($this->targetDirs[1].'/array.json'); break;
default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
$this->loadedDynamicParameters[$name] = true;
@ -144,6 +137,7 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
'project_dir' => '/foo/bar',
'env(FOO)' => 'foo',
'env(DB)' => 'sqlite://%project_dir%/var/data.db',
'env(json_file)' => (\dirname(__DIR__, 1).'/array.json'),
];
}
}

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -265,7 +265,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'method_call1' shared service.
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
$this->services['method_call1'] = $instance = new \Bar\FooClass();
@ -300,7 +300,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'non_shared_foo' service.
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
$this->factories['non_shared_foo'] = function () {
return new \Bar\FooClass();
@ -374,17 +374,14 @@ class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $targetDir;
private $parameters = [];
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->targetDir = \dirname($containerDir);
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -40,17 +40,14 @@ class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $targetDir;
private $parameters = [];
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->targetDir = \dirname($containerDir);
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -90,8 +87,8 @@ class ProjectServiceContainer extends Container
'decorated' => 'decorator_service_with_name',
];
$this->privates['service_container'] = static function () {
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
$this->privates['service_container'] = function () {
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
};
}
@ -287,7 +284,7 @@ class ProjectServiceContainer extends Container
*/
protected function getFoo_BazService()
{
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php';
include_once $this->targetDir.''.'/Fixtures/includes/classes.php';
$this->services['foo.baz'] = $instance = \BazClass::getInstance();
@ -331,7 +328,7 @@ class ProjectServiceContainer extends Container
*/
protected function getLazyContextService()
{
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php';
include_once $this->targetDir.''.'/Fixtures/includes/classes.php';
return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () {
yield 'k1' => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
@ -348,7 +345,7 @@ class ProjectServiceContainer extends Container
*/
protected function getLazyContextIgnoreInvalidRefService()
{
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php';
include_once $this->targetDir.''.'/Fixtures/includes/classes.php';
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
yield 0 => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
@ -364,7 +361,7 @@ class ProjectServiceContainer extends Container
*/
protected function getMethodCall1Service()
{
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
$this->services['method_call1'] = $instance = new \Bar\FooClass();
@ -399,7 +396,7 @@ class ProjectServiceContainer extends Container
*/
protected function getNonSharedFooService()
{
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
return new \Bar\FooClass();
}

View File

@ -30,17 +30,14 @@ class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $targetDir;
private $parameters = [];
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->targetDir = \dirname($containerDir);
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -92,7 +89,7 @@ class ProjectServiceContainer extends Container
});
}
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo_lazy.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo_lazy.php';
return new \Bar\FooClass(new \Bar\FooLazyClass());
}
@ -161,7 +158,7 @@ class ProjectServiceContainer extends Container
];
}
}
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
class FooClass_%s extends \Bar\FooClass implements \ProxyManager\Proxy\VirtualProxyInterface
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{
$dir = __DIR__;
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -63,7 +58,7 @@ class ProjectServiceContainer extends Container
{
$this->services['bar'] = $instance = new \BarClass();
$instance->setBaz($this->parameters['array_1'], $this->getParameter('array_2'), '%array_1%', $this->parameters['array_1']);
$instance->setBaz($this->parameters['array_1'], $this->parameters['array_2'], '%array_1%', $this->parameters['array_1']);
return $instance;
}
@ -107,22 +102,12 @@ class ProjectServiceContainer extends Container
return $this->parameterBag;
}
private $loadedDynamicParameters = [
'array_2' => false,
];
private $loadedDynamicParameters = [];
private $dynamicParameters = [];
private function getDynamicParameter(string $name)
{
switch ($name) {
case 'array_2': $value = [
0 => ($this->targetDirs[2].'/Dumper'),
]; break;
default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
$this->loadedDynamicParameters[$name] = true;
return $this->dynamicParameters[$name] = $value;
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
protected function getDefaultParameters(): array
@ -131,6 +116,9 @@ class ProjectServiceContainer extends Container
'array_1' => [
0 => 123,
],
'array_2' => [
0 => (\dirname(__DIR__, 2).'/Dumper'),
],
];
}
}

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_CsvParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Deep_Graph extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Errored_Definition extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{
$dir = __DIR__;
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
@ -37,11 +32,11 @@ class ProjectServiceContainer extends Container
$this->aliases = [];
$this->privates['service_container'] = static function () {
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/I1.php';
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/P1.php';
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/T1.php';
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C1.php';
$this->privates['service_container'] = function () {
include_once \dirname(__DIR__, 1).'/includes/HotPath/I1.php';
include_once \dirname(__DIR__, 1).'/includes/HotPath/P1.php';
include_once \dirname(__DIR__, 1).'/includes/HotPath/T1.php';
include_once \dirname(__DIR__, 1).'/includes/HotPath/C1.php';
};
}
@ -91,8 +86,8 @@ class ProjectServiceContainer extends Container
*/
protected function getC2Service()
{
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C2.php';
include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C3.php';
include_once \dirname(__DIR__, 1).'/includes/HotPath/C2.php';
include_once \dirname(__DIR__, 1).'/includes/HotPath/C3.php';
return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3());
}

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Inline_Self_Ref extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_JsonParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'non_shared_foo' service.
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo_lazy.php';
include_once $this->targetDir.''.'/Fixtures/includes/foo_lazy.php';
$this->factories['non_shared_foo'] = function ($lazyLoad = true) {
return new \Bar\FooLazyClass();
@ -46,17 +46,14 @@ class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $targetDir;
private $parameters = [];
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->targetDir = \dirname($containerDir);
$this->services = $this->privates = [];
$this->fileMap = [
'non_shared_foo' => 'getNonSharedFooService.php',

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_QueryStringParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container
{
private $parameters = [];
private $targetDirs = [];
private $getService;
public function __construct()

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container
{
private $parameters = [];
private $targetDirs = [];
private $getService;
public function __construct()

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
private $getService;
public function __construct()

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ProjectServiceContainer extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_Unsupported_Characters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Test_UrlParameters extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{

View File

@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class Symfony_DI_PhpDumper_Service_Wither extends Container
{
private $parameters = [];
private $targetDirs = [];
public function __construct()
{