bug #24954 [DI] Fix dumping with custom base class (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[DI] Fix dumping with custom base class

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24948
| License       | MIT
| Doc PR        | -

ping @kbond please confirm it's OK for you

Commits
-------

2dd74ab [DI] Fix dumping with custom base class
This commit is contained in:
Nicolas Grekas 2017-11-13 19:15:33 +01:00
commit 772f29fd25
2 changed files with 7 additions and 3 deletions

View File

@ -112,7 +112,11 @@ class PhpDumper extends Dumper
'debug' => true,
), $options);
$this->initializeMethodNamesMap($options['base_class']);
if (0 !== strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) {
$baseClass = sprintf('%s\%s', $options['namespace'] ? '\\'.$options['namespace'] : '', $baseClass);
}
$this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass);
$this->docStar = $options['debug'] ? '*' : '';
@ -141,7 +145,7 @@ class PhpDumper extends Dumper
}
}
$code = $this->startClass($options['class'], $options['base_class'], $options['namespace']);
$code = $this->startClass($options['class'], $baseClass, $options['namespace']);
if ($this->container->isCompiled()) {
$code .= $this->addFrozenConstructor();

View File

@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
*
* @final since Symfony 3.3
*/
class Container extends AbstractContainer
class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer
{
private $parameters;
private $targetDirs = array();