Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@skafandri

Description

@skafandri
Issue body actions
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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.