Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ruudk opened this issue May 30, 2022 · 1 comment
Closed

Comments

@ruudk
Copy link
Contributor

ruudk commented May 30, 2022

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

@ruudk ruudk changed the title [6.1] [AbstractBundle] Call to an undefined method Symfony\Component\Config\Definition\Builder\NodeDefinition::children() [6.1] [AbstractBundle] Call to an undefined method NodeDefinition::children() May 30, 2022
@ruudk ruudk closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant