Skip to content

[Config] The config builder should reject required parameter with a default value #62076

@GromNaN

Description

@GromNaN

Description

isRequired() is not compatible with a default value, as the default value is ignored. And exception should be thrown when a config tree node has both.

This can be deprecated in 7.4 and fail in 8.0.

Example

The following config tree should fail before processing a configuration.

$definition->rootNode()->children()
    ->scalarNode('api_key')
    ->defaultValue('%env(OPENAI_API_KEY)%')
    ->info('OpenAI API Key used to authenticate with the OpenAI API');

Found with openai-php/symfony#36, fixed by openai-php/symfony@2e6d30a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions