Skip to content

Conversation

@Crell
Copy link
Collaborator

@Crell Crell commented Jun 1, 2022

I actually quite detest the extra space after the fn, and find it hard to read and write. However, it is enforced by coding style tools now and is consistent with the long-closure form, which also requires the extra space.

The rest is, I think, uncontroversial. (I hope.)

@Crell Crell mentioned this pull request Jun 1, 2022
25 tasks
@Crell Crell force-pushed the short-closures branch from aaade6f to f2c68cf Compare June 1, 2022 22:18
@samdark samdark added the enhancement New feature or request label Jun 2, 2022
fruitl00p added a commit to fruitl00p/per-coding-style that referenced this pull request Jun 23, 2022
… classes) According to chapter 4: > ## 4. Classes, Properties, and Methods > > The term "class" refers to all classes, interfaces, and traits. > > Any closing brace MUST NOT be followed by any comment or statement on the same line. > > When instantiating a new class, parentheses MUST always be present even when there are no arguments passed to the constructor. This MR updates the spec to adhere to that rule on anonymous classes too. (taken from moved from php-fig/fig-standards#1283 but also builds upon php-fig#17)
@KorvinSzanto
Copy link
Contributor

I'm really not a fan of that long form short closure but I don't really have any suggestions to improve it for now.

@KorvinSzanto KorvinSzanto merged commit ab177f2 into php-fig:master Jul 17, 2022
@Crell Crell deleted the short-closures branch July 18, 2022 15:56
@theodorejb
Copy link
Contributor

I think this was a mistake. The fact that PHP-CS-Fixer previously enforced spacing after the fn keyword using the same setting as for the function keyword was a bug, and has been corrected now with the addition of a separate closure_fn_spacing setting. Is there any other PSR-12 tooling that enforces a space after the fn keyword by default? PhpStorm specifically formats arrow functions with no space after the keyword. Note that this is how arrow functions were intended to be written per the RFC author.

The primary intention for arrow functions is to avoid much of the verbosity of anonymous functions, and requiring a space after the fn keyword is a step backwards from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

4 participants