Skip to content

[DI] Error on dumped container for inlined services #28658

Closed
@andrew-demb

Description

@andrew-demb

Symfony version(s) affected: 3.4.16

Description
After update to 3.4.16 version inlined dependencies (in my case with circular dependencies) dumped with use $this->privates value from the container for return as service.
But every value from $this->privates is a boolean.

How to reproduce

git clone https://github.com/andrew-demb/sf-di-3.4.16-circular-reference-dump.git
cd sf-di-3.4.16-circular-reference-dump/
php bug.php

Additional context
Repository with reproduce script: https://github.com/andrew-demb/sf-di-3.4.16-circular-reference-dump

This PR #28388 represents a change for PhpDumper to use privates in dumped container.

Some pieces from cached container:

class ProjectServiceContainer extends Container
{
    private $parameters;
    private $targetDirs = array();

    public function __construct()
    {
        $this->services = array();
        $this->methodMap = array(
            'service_one' => 'getServiceOneService',
            'service_two' => 'getServiceTwoService',
        );
        $this->privates = array(
            'service_one' => true,
            'service_two' => true,
        );

        $this->aliases = array();
    }
// ...
    protected function getServiceTwoService()
    {
        $a = ${($_ = isset($this->services['service_one']) ? $this->services['service_one'] : $this->getServiceOneService()) && false ?: '_'};

        if (isset($this->privates['service_two'])) {
            return $this->privates['service_two'];
        }

        return $this->services['service_two'] = new \ArrayObject(array('source' => $a));
    }

YAML config

services:
    service_one:
        class: ArrayObject
        calls:
            - [ offsetSet, ['sv', '@service_two'] ]

    service_two:
        class: ArrayObject
        arguments:
            -
                source: '@service_one'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions