Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,13 @@ public function __construct()
if ($this->container->isCompiled()) {
if (Container::class !== $baseClassWithNamespace) {
$r = $this->container->getReflectionClass($baseClassWithNamespace, false);

if (null !== $r && (null !== $constructor = $r->getConstructor()) && 0 === $constructor->getNumberOfRequiredParameters()) {
$code .= " parent::__construct();\n\n";
if (null !== $r
&& (null !== $constructor = $r->getConstructor())
&& 0 === $constructor->getNumberOfRequiredParameters()
&& Container::class !== $constructor->getDeclaringClass()->name
) {
$code .= " parent::__construct();\n";
$code .= " \$this->parameterBag = null;\n\n";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

class NoConstructorContainer
use Symfony\Component\DependencyInjection\Container;

class NoConstructorContainer extends Container
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a new test case to still keep the existing one (a class without a constructor not inheriting one from its base class)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking about that .. and to me the old test just seemed incomplete since that class didn't even implement the interface.

{
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tes
public function __construct()
{
parent::__construct();
$this->parameterBag = null;

$this->services = array();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tes
public function __construct()
{
parent::__construct();
$this->parameterBag = null;

$this->services = array();

Expand Down