fix regression when extending the Container class without a constructor
regression introduced in c026ec63e3 (diff-f7b23d463cba27ac5e4cb677f2be7623R985)
This commit is contained in:
parent
07cccd53df
commit
0beb64a77c
@ -981,9 +981,13 @@ EOF;
|
|||||||
if ($this->container->isCompiled()) {
|
if ($this->container->isCompiled()) {
|
||||||
if (Container::class !== $baseClassWithNamespace) {
|
if (Container::class !== $baseClassWithNamespace) {
|
||||||
$r = $this->container->getReflectionClass($baseClassWithNamespace, false);
|
$r = $this->container->getReflectionClass($baseClassWithNamespace, false);
|
||||||
|
if (null !== $r
|
||||||
if (null !== $r && (null !== $constructor = $r->getConstructor()) && 0 === $constructor->getNumberOfRequiredParameters()) {
|
&& (null !== $constructor = $r->getConstructor())
|
||||||
$code .= " parent::__construct();\n\n";
|
&& 0 === $constructor->getNumberOfRequiredParameters()
|
||||||
|
&& Container::class !== $constructor->getDeclaringClass()->name
|
||||||
|
) {
|
||||||
|
$code .= " parent::__construct();\n";
|
||||||
|
$code .= " \$this->parameterBag = null;\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Container;
|
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Container;
|
||||||
|
|
||||||
class NoConstructorContainer
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
|
||||||
|
class NoConstructorContainer extends Container
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tes
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->parameterBag = null;
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tes
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->parameterBag = null;
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user