Skip to content

Lambdas are a thing now #32

@okonomiyaki3000

Description

@okonomiyaki3000

I think the standard needs to be relaxed a little bit for lambdas (if possible).
For example:

$mapped = array_map(function ($a) { return $a->prop; }, $someObjects);

Will produce two phpcs errors:

  • Closing brace must be on a line by itself
  • Each PHP statement must be on a line by itself

So then, you might try:

$mapped = array_map(function ($a) {
        return $a->prop;
    }, 
    $someObjects
);

Which is already terrible but then you get:

  • Opening parenthesis of a multi-line function call must be the last content on the line
  • Closing brace indented incorrectly; expected 2 spaces, found 3

So you try:

$mapped = array_map(
    function ($a) {
        return $a->prop;
    }, 
    $someObjects
);

And somehow it works but it's hideous.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions