Skip to content

[6.1] [AbstractBundle] Call to an undefined method NodeDefinition::children() #278

@ruudk

Description

@ruudk

When using the new Symfony 6.1 AbstractBundle introduced in symfony/symfony#43701 I'm getting the following error:

final class GraphQLBundle extends AbstractBundle
{
    public function configure(DefinitionConfigurator $definition) : void
    {
        $definition
            ->rootNode()
            ->children()  // Call to an undefined method Symfony\Component\Config\Definition\Builder\NodeDefinition::children().
                ->integerNode('debug_flag')
                    ->defaultValue(DebugFlag::NONE)
                    ->isRequired()
                    ->end()
            ->end();
    }
}

I think this is because DefinitionConfigurator::rootNode() returns NodeDefinition|ArrayNodeDefinition. It will always return a ArrayNodeDefinition. Maybe the return type should be changed in Symfony to reflect that?

The TreeBuilderGetRootNodeDynamicReturnTypeExtension won't work anymore because the TreeBuilder instance is created by Symfony for you.

I don't really know what's the best way to solve this in PHPStan. Create a new extension that overwrites the rootNode() method's return type?

/cc @yceruto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions