Skip to content

[Config] Missing namespace in generated config classes constructor #40921

Closed
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected: 5.3.0-BETA1

Description
When a config class is generated, config classes in their constructor are missing their namespace. This is because in

$code = 'array_map(function($v) { return new '.$p->getType().'($v); }, $value["ORG_NAME"]);';
getType does not include it.

How to reproduce
See #40921 (comment)

In my cache.php config file

$config->cache(['pools' => [[
    'adapters' => 'my.dedicated.cache',
]]]);

calls Symfony\Config\Framework\CacheConfig constructor, which contains

if (isset($value["pools"])) {
    $this->pools = array_map(function($v) { return new PoolConfig($v); }, $value["pools"]);;
    unset($value["pools"]);
}

PoolConfig is in the Symfony\Config\Framework\Cache namespace so it results in

Attempted to load class "PoolConfig" from namespace "Symfony\Config\Framework".
Did you forget a "use" statement for another namespace?

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