Skip to content

[Config] Provide shorthand methods for ArrayNodeDefinition::prototype() #20921

Closed
@skafandri

Description

@skafandri
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version master

ArrayNodeDefinition::prototype() returns a NodeDefinition. However in reality it returns an IntegerNodeDefinition, ArrayNodeDefinition and so on.

This makes the last line of the following code ->max(10) not recognizable by IDEs and with a bit TreeBuilder is can become annoying

$node = new ArrayNodeDefinition('name');
$node
    ->prototype('integer')
    ->max(10);

I propose to provide shorthand methods for the standard node types (variable, scalar, boolean, integer, float, array, enum)

So the previous snippet could be written as

$node = new ArrayNodeDefinition('name');
$node
    ->prototypeInteger()
    ->max(10);

As a result, your IDE will recognize that it returns NumericNodeDefinition and can follow the call.

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