Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Closures (anonymous functions) are currently erroneously marked with a style warning: Functions should be called with no spaces between the function name and opening parentheses
.
Comment | File | Size | Author |
---|---|---|---|
#1 | coder-closures-1272900.patch | 694 bytes | smk-ka |
Comments
Comment #1
smk-ka CreditAttribution: smk-ka commentedAdded
function
to the list of ignored words.Comment #2
douggreen CreditAttribution: douggreen commentedI applied, tested the results before and after, and this did no harm, because Drupal core doesn't use anonymous functions. I applied but we should probably write a test case for this, so leaving open.
Comment #3
douggreen CreditAttribution: douggreen commentedComment #4
hefox CreditAttribution: hefox commentedTo clarify
is correct spacing as function is a keyword in this case? (vs. function($what)
Comment #5
thursday_bw CreditAttribution: thursday_bw commentedI'm having issue with closures and anonymous functions..
example:
gives:
Which is just silly.. but then if I do indent line 187 to 28 spaces. I instead get
as a side not, this anonymous function was originally passed straight to array_map like so:
Which gives the same behaviour as described above.
Comment #6
thursday_bw CreditAttribution: thursday_bw commentedMore info.. It appears that this is the result of having a closer in a closure. :/
the code snippet above, is I've found now to be nested in an existing closer..
there are no errors about the parent closure.
Comment #7
thursday_bw CreditAttribution: thursday_bw commentedOK.. My last to comments were admittedly a bit blah.
For clarification I have included various examples of closures in different contexts.
Many of these pass the tests, but the last couple fail.
Please let me know if this belongs in it's own thread.
Comment #8
shrop CreditAttribution: shrop commentedI am also running into an issue where using anonymous functions causes subsequent lines of code to be falsely flagged as having the wrong indentions.
Comment #9
micromegas CreditAttribution: micromegas commentedI confirm closures are causing issues. For example, if you run coder sniffer on the following file, it will erroneously mark the closure bodies as having incorrect indentation.
Even if you change the indentation to satisfy coder, it still gives the indentation error, asking for the number of spaces that it was before you changed it.
Comment #10
markdorisonComment #11
klausiThose example closures now all work as expected with the latest Coder release.