8000 Merge branch '2.6' into 2.7 · symfony/symfony@79a5fdd · GitHub
[go: up one dir, main page]

Skip to content

Commit 79a5fdd

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: [DependencyInjection] keep some of the reverted perf optim Revert "minor #10241 [DependencyInjection] made some perf improvements (fabpot)" Remove deprecated class
2 parents 5ada72e + 73149ae commit 79a5fdd

File tree

12 files changed

+80
-145
lines changed

12 files changed

+80
-145
lines changed

src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\HttpKernel\Exception\FlattenException;
14+
use Symfony\Component\Debug\Exception\FlattenException;
1515
use Symfony\Component\HttpKernel\HttpKernelInterface;
1616
use Symfony\Component\HttpFoundation\Request;
1717

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ private function startClass($class, $baseClass, $namespace)
823823
*/
824824
class $class extends $baseClass
825825
{
826+
private \$parameters;
827+
826828
EOF;
827829
}
828830

@@ -837,14 +839,14 @@ private function addConstructor()
837839

838840
$code = <<<EOF
839841
840-
private static \$parameters = $parameters;
841-
842842
/**
843843
* Constructor.
844844
*/
845845
public function __construct()
846846
{
847-
parent::__construct(new ParameterBag(self::\$parameters));
847+
\$this->parameters = $parameters;
848+
849+
parent::__construct(new ParameterBag(\$this->parameters));
848850
849851
EOF;
850852

@@ -876,8 +878,6 @@ private function addFrozenConstructor()
876878

877879
$code = <<<EOF
878880
879-
private static \$parameters = $parameters;
880-
881881
/**
882882
* Constructor.
883883
*/
@@ -886,6 +886,7 @@ public function __construct()
886886
\$this->services =
887887
\$this->scopedServices =
888888
\$this->scopeStacks = array();
889+
\$this->parameters = $parameters;
889890
890891
\$this->set('service_container', \$this);
891892
@@ -1001,11 +1002,11 @@ public function getParameter(\$name)
10011002
{
10021003
\$name = strtolower(\$name);
10031004
1004-
if (!(isset(self::\$parameters[\$name]) || array_key_exists(\$name, self::\$parameters))) {
1005+
if (!(isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) {
10051006
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name));
10061007
}
10071008
1008-
return self::\$parameters[\$name];
1009+
return \$this->parameters[\$name];
10091010
}
10101011
10111012
/**
@@ -1015,7 +1016,7 @@ public function hasParameter(\$name)
10151016
{
10161017
\$name = strtolower(\$name);
10171018
1018-
return isset(self::\$parameters[\$name]) || array_key_exists(\$name, self::\$parameters);
1019+
return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters);
10191020
}
10201021
10211022
/**
@@ -1032,7 +1033,7 @@ public function setParameter(\$name, \$value)
10321033
public function getParameterBag()
10331034
{
10341035
if (null === \$this->parameterBag) {
1035-
\$this->parameterBag = new FrozenParameterBag(self::\$parameters);
1036+
\$this->parameterBag = new FrozenParameterBag(\$this->parameters);
10361037
}
10371038
10381039
return \$this->parameterBag;

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ public function testDump()
3737
new PhpDumper($container);
3838
}
3939

40-
public function testDumpFrozenContainerWithNoParameter()
41-
{
42-
$container = new ContainerBuilder();
43-
$container->setResourceTracking(false);
44-
$container->register('foo', 'stdClass');
45-
46-
$container->compile();
47-
48-
$dumper = new PhpDumper($container);
49-
50-
$dumpedString = $dumper->dump();
51-
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.');
52-
$this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.');
53-
}
54-
5540
public function testDumpOptimizationString()
5641
{
5742
$definition = new Definition();

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717
*/
1818
class Container extends AbstractContainer
1919
{
20-
private static $parameters = array(
21-
22-
);
20+
private $parameters;
2321

2422
/**
2523
* Constructor.
2624
*/
2725
public function __construct()
2826
{
29-
parent::__construct(new ParameterBag(self::$parameters));
27+
$this->parameters = array(
28+
29+
);
30+
31+
parent::__construct(new ParameterBag($this->parameters));
3032
}
3133
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
*/
1717
class ProjectServiceContainer extends Container
1818
{
19-
private static $parameters = array(
20-
21-
);
19+
private $parameters;
2220

2321
/**
2422
* Constructor.
2523
*/
2624
public function __construct()
2725
{
28-
parent::__construct(new ParameterBag(self::$parameters));
26+
$this->parameters = array(
27+
28+
);
29+
30+
parent::__construct(new ParameterBag($this->parameters));
2931
}
3032
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
*/
1717
class ProjectServiceContainer extends Container
1818
{
19-
private static $parameters = array(
20-
'empty_value' => '',
21-
'some_string' => '-',
22-
);
19+
private $parameters;
2320

2421
/**
2522
* Constructor.
@@ -29,6 +26,10 @@ public function __construct()
2926
$this->services =
3027
$this->scopedServices =
3128
$this->scopeStacks = array();
29+
$this->parameters = array(
30+
'empty_value' => '',
31+
'some_string' => '-',
32+
);
3233

3334
$this->set('service_container', $this);
3435

@@ -69,11 +70,11 @@ public function getParameter($name)
6970
{
7071
$name = strtolower($name);
7172

72-
if (!(isset(self::$parameters[$name]) || array_key_exists($name, self::$parameters))) {
73+
if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
7374
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
7475
}
7576

76-
return self::$parameters[$name];
77+
return $this->parameters[$name];
7778
}
7879

7980
/**
@@ -83,7 +84,7 @@ public function hasParameter($name)
8384
{
8485
$name = strtolower($name);
8586

86-
return isset(self::$parameters[$name]) || array_key_exists($name, self::$parameters);
87+
return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
8788
}
8889

8990
/**
@@ -100,7 +101,7 @@ public function setParameter($name, $value)
100101
public function getParameterBag()
101102
{
102103
if (null === $this->parameterBag) {
103-
$this->parameterBag = new FrozenParameterBag(self::$parameters);
104+
$this->parameterBag = new FrozenParameterBag($this->parameters);
104105
}
105106

106107
return $this->parameterBag;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@
1616
*/
1717
class ProjectServiceContainer extends Container
1818
{
19+
private $parameters;
20+
1921
/**
2022
* Constructor.
2123
*/
2224
public function __construct()
2325
{
24-
$this->parameters = $this->getDefaultParameters();
25-
2626
$this->services =
2727
$this->scopedServices =
2828
$this->scopeStacks = array();
29+
$this->parameters = array(
30+
'foo' => ('wiz'.dirname(__DIR__)),
31+
'bar' => __DIR__,
32+
'baz' => (__DIR__.'/PhpDumperTest.php'),
33+
);
2934

3035
$this->set('service_container', $this);
3136

@@ -38,6 +43,14 @@ public function __construct()
3843
$this->aliases = array();
3944
}
4045

46+
/**
47+
* {@inheritdoc}
48+
*/
49+
public function compile()
50+
{
51+
throw new LogicException('You cannot compile a dumped frozen container.');
52+
}
53+
4154
/**
4255
* Gets the 'test' service.
4356
*
@@ -94,17 +107,4 @@ public function getParameterBag()
94107

95108
return $this->parameterBag;
96109
}
97-
/**
98-
* Gets the default parameters.
99-
*
100-
* @return array An array of the default parameters
101-
*/
102-
protected function getDefaultParameters()
103-
{
104-
return array(
105-
'foo' => ('wiz'.dirname(__DIR__)),
106-
'bar' => __DIR__,
107-
'baz' => (__DIR__.'/PhpDumperTest.php'),
108-
);
109-
}
110110
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
*/
1717
class ProjectServiceContainer extends Container
1818
{
19-
private static $parameters = array(
20-
21-
);
19+
private $parameters;
2220

2321
/**
2422
* Constructor.
2523
*/
2624
public function __construct()
2725
{
28-
parent::__construct(new ParameterBag(self::$parameters));
26+
$this->parameters = array(
27+
28+
);
29+
30+
parent::__construct(new ParameterBag($this->parameters));
2931
$this->methodMap = array(
3032
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
3133
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
*/
1717
class ProjectServiceContainer extends Container
1818
{
19-
private static $parameters = array(
19+
private $parameters;
20+
21+
/**
22+
* Constructor.
23+
*/
24+
public function __construct()
25+
{
26+
$this->parameters = array(
2027
'foo' => '%baz%',
2128
'baz' => 'bar',
2229
'bar' => 'foo is %%foo bar',
@@ -33,11 +40,6 @@ class ProjectServiceContainer extends Container
3340
),
3441
);
3542

36-
/**
37-
* Constructor.
38-
*/
39-
public function __construct()
40-
{
41-
parent::__construct(new ParameterBag(self::$parameters));
43+
parent::__construct(new ParameterBag($this->parameters));
4244
}
4345
}

0 commit comments

Comments
 (0)
0