Skip to content

Commit d4072a0

Browse files
committed
ContainerBuilder::formatPhp() fixed compatibility when method is called directly
1 parent 64e9a08 commit d4072a0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/DI/ContainerBuilder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ public function complete()
581581

582582

583583
/**
584-
* @return void
584+
* @return Statement
585585
*/
586586
public function completeStatement(Statement $statement)
587587
{
@@ -934,9 +934,17 @@ public function formatPhp($statement, $args)
934934
{
935935
array_walk_recursive($args, function (& $val) {
936936
if ($val instanceof Statement) {
937-
$val = self::literal($this->formatStatement($val));
937+
$val = self::literal($this->formatStatement($this->completeStatement($val)));
938+
939+
} elseif ($val === $this) {
940+
trigger_error("Replace object ContainerBuilder in Statement arguments with '@container'.", E_USER_DEPRECATED);
941+
$val = self::literal('$this');
942+
943+
} elseif ($val instanceof ServiceDefinition) {
944+
$val = '@' . current(array_keys($this->getDefinitions(), $val, TRUE));
945+
}
938946

939-
} elseif (is_string($val) && substr($val, 0, 2) === '@@') { // escaped text @@
947+
if (is_string($val) && substr($val, 0, 2) === '@@') { // escaped text @@
940948
$val = substr($val, 1);
941949

942950
} elseif (is_string($val) && substr($val, 0, 1) === '@' && strlen($val) > 1) { // service reference

0 commit comments

Comments
 (0)