Skip to content

Commit ae94ed6

Browse files
committed
fix regression when extending the Container class without a constructor
regression introduced in c026ec6#diff-f7b23d463cba27ac5e4cb677f2be7623R985
1 parent 07cccd5 commit ae94ed6

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,13 @@ public function __construct()
981981
if ($this->container->isCompiled()) {
982982
if (Container::class !== $baseClassWithNamespace) {
983983
$r = $this->container->getReflectionClass($baseClassWithNamespace, false);
984-
985-
if (null !== $r && (null !== $constructor = $r->getConstructor()) && 0 === $constructor->getNumberOfRequiredParameters()) {
986-
$code .= " parent::__construct();\n\n";
984+
if (null !== $r
985+
&& (null !== $constructor = $r->getConstructor())
986+
&& 0 === $constructor->getNumberOfRequiredParameters()
987+
&& $constructor->getDeclaringClass()->name !== Container::class
988+
) {
989+
$code .= " parent::__construct();\n";
990+
$code .= " \$this->parameterBag = null;\n\n";
987991
}
988992
}
989993

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Container/NoConstructorContainer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Container;
44

5-
class NoConstructorContainer
5+
use Symfony\Component\DependencyInjection\Container;
6+
7+
class NoConstructorContainer extends Container
68
{
79
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tes
2424
public function __construct()
2525
{
2626
parent::__construct();
27+
$this->parameterBag = null;
2728

2829
$this->services = array();
2930

0 commit comments

Comments
 (0)