Skip to content

Commit

Permalink
bug #21942 [DI] Fix dumping null ServiceClosureArgument (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Fix dumping null ServiceClosureArgument

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

Commits
-------

35977fd [DI] Fix dumping null ServiceClosureArgument
  • Loading branch information
nicolas-grekas committed Mar 9, 2017
2 parents 7f6f402 + 35977fd commit 5b1a96a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Expand Up @@ -1690,7 +1690,7 @@ private function dumpValue($value, $interpolate = true)
return $this->export($value);
}

private function dumpServiceClosure(Reference $reference, $interpolate, $oneLine)
private function dumpServiceClosure(Reference $reference = null, $interpolate, $oneLine)
{
$code = $this->dumpValue($reference, $interpolate);

Expand Down
Expand Up @@ -657,8 +657,10 @@ public function testServiceLocator()
->addArgument(array(
'bar' => new ServiceClosureArgument(new Reference('bar_service')),
'baz' => new ServiceClosureArgument(new TypedReference('baz_service', 'stdClass')),
'nil' => $nil = new ServiceClosureArgument(new Reference('nil')),
))
;
$nil->setValues(array(null));
$container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')));
$container->register('baz_service', 'stdClass')->setPublic(false);
$container->compile();
Expand Down
Expand Up @@ -88,6 +88,8 @@ protected function getFooServiceService()
return ${($_ = isset($this->services['bar_service']) ? $this->services['bar_service'] : $this->get('bar_service')) && false ?: '_'};
}, 'baz' => function () {
$f = function (\stdClass $v) { return $v; }; return $f(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'});
}, 'nil' => function () {
return NULL;
}));
}

Expand Down

0 comments on commit 5b1a96a

Please sign in to comment.