Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambdas are a thing now #32

Open
okonomiyaki3000 opened this issue Oct 2, 2013 · 1 comment
Open

Lambdas are a thing now #32

okonomiyaki3000 opened this issue Oct 2, 2013 · 1 comment

Comments

@okonomiyaki3000
Copy link

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.

@photodude
Copy link
Contributor

Technically it's related to PHPCS and the built-in rules that we borrow from.
the rules that are thrown from the first code snip are
PEAR.Functions.FunctionDeclaration.ContentAfterBrace
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore
Generic.Formatting.DisallowMultipleStatements.SameLine

To solve this we likely need to open an issue with PHPCS relating to lambda parsing and possibly exclusions for lambdas (there might be an open issue with PHPCS on this to join in on).

wilsonge pushed a commit to wilsonge/coding-standards that referenced this issue Oct 1, 2018
Removes checks in execute for a connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants