Skip to content

[Config] Transform a value into an array #21817

Closed
@javiereguiluz

Description

@javiereguiluz
Q A
Bug report? no
Feature request? yes
BC Break report? no
Symfony version 3.x

In config trees is common to see code like the following to turn a value into an array:

->beforeNormalization()
   ->ifTrue(function ($v) { return !is_array($v); })
    ->then(function ($v) { return array($v); })
->end()

// ...

->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()

You can see it tens of times in Symfony, popular bundles and elsewhere. Could we add a helper method to remove this boilerplate code? Thanks!

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