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] Transform a value into an array #21817

Copy link
Copy link
Closed
@javiereguiluz

Description

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

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