Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Aug 06, 2012
@hidenorigoto hidenorigoto [DependencyInjection] Added a test for a frozen constructor of a cont…
…ainer with no parameters
2a124bc
@hidenorigoto hidenorigoto [DependencyInjection] Fixed a frozen constructor of a container with …
…no parameters
1a4a4ee
Commits on Aug 10, 2012
@fabpot fabpot merged branch hidenorigoto/fix-di-phpdumper (PR #5194)
Commits
-------

1a4a4ee [DependencyInjection] Fixed a frozen constructor of a container with no parameters
2a124bc [DependencyInjection] Added a test for a frozen constructor of a container with no parameters

Discussion
----------

[DependencyInjection] Fix PHP Dumper for a constructor of a frozen container with no parameters

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:
Todo: -
License of the code: MIT

---------------------------------------------------------------------------

by travisbot at 2012-08-06T16:51:20Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/2049206) (merged 1a4a4ee into 3d32a0b).
ee572b3
View
8 src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -689,7 +689,13 @@ private function addFrozenConstructor()
*/
public function __construct()
{
- \$this->parameters = \$this->getDefaultParameters();
+EOF;
+
+ if ($this->container->getParameterBag()->all()) {
+ $code .= "\n \$this->parameters = \$this->getDefaultParameters();\n";
+ }
+
+ $code .= <<<EOF
\$this->services =
\$this->scopedServices =
View
14 tests/Symfony/Tests/Component/DependencyInjection/Dumper/PhpDumperTest.php
@@ -37,6 +37,20 @@ public function testDump()
new PhpDumper($container);
}
+ public function testDumpFrozenContainerWithNoParameter()
+ {
+ $container = new ContainerBuilder();
+ $container->register('foo', 'stdClass');
+
+ $container->compile();
+
+ $dumper = new PhpDumper($container);
+
+ $dumpedString = $dumper->dump();
+ $this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.');
+ $this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.');
+ }
+
public function testDumpOptimizationString()
{
$definition = new Definition();
View
45 tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services11.php
@@ -0,0 +1,45 @@
+<?php
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Container;
+use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Parameter;
+use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
+
+/**
+ * ProjectServiceContainer
+ *
+ * This class has been auto-generated
+ * by the Symfony Dependency Injection Component.
+ */
+class ProjectServiceContainer extends Container
+{
+ /**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ $this->services =
+ $this->scopedServices =
+ $this->scopeStacks = array();
+
+ $this->set('service_container', $this);
+
+ $this->scopes = array();
+ $this->scopeChildren = array();
+ }
+
+ /**
+ * Gets the 'foo' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return stdClass A stdClass instance.
+ */
+ protected function getFooService()
+ {
+ return $this->services['foo'] = new \stdClass();
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.