Closed Hywan closed 9 years ago
We must define how block works. Here is my proposal:
{
a single statement;
}
{
more;
than;
one;
statement;
}
No newline after and before {
and }
if we have a single statement. Newlines if we have more than one statement. Concrete example:
if (true === $foo) {
doSomething();
} else {
$a++;
$b = str_replace(…, …, …);
}
Now, how to treat the special case of the return
statement? Does it count as a statement? The rule is: If we have 0 or 1 statement and a return, we do not add any newline. If we have more than 1 statement and a return, we add newline and an empty line before the return
. Like this:
{
a single statement;
return;
}
{
a statement;
another statement;
return;
}
Thoughts?
Update: break
, continue
and exit
have the same rule as return
.
/cc @hoaproject/hoackers
Example of a PR: https://github.com/hoaproject/Websocket/pull/34.
Need to retouch manually for the block and return
family. Everything else is pretty much perfect (sometimes we have to fix some stuff manually, nothing horrible).
Looks good but I think you inverted the @throws
tag name normalization, according to phpdoc.org and php-cs-fixer:phpdoc_params [symfony] @throw
doesn't exist.
@Metalaka ;-) :+1:
What about newlines in blocks? I am still not sure what to do…
I propose to not add newlines with the block contains one or more statements.
Done. PR is ready to be applied. I would like all @hoaproject/hoackers to review this result: https://github.com/hoaproject/Websocket/pull/34/files please :-). Report everything on this link, no this page.
Thanks!
This PR introduces:
hoa devtools:cs fix .
to automatically run php-cs-fixer and automatically link to the following configuration file,phpdoc_var
(fix@var
),phpdoc_access
(remove@access
),php_throws
(replace@throws
by@throw
),author
(remove `@author),copyright
(update and fix copyrights),block
(fix newlines in blocks),return
(fix newlines with return),indent_concatenation
(everything must be indented, even concatenation).I let you take a look at the API documentation explaining the fixers.
Fix https://github.com/hoaproject/Websocket/pull/25. Fix https://github.com/hoaproject/Central/issues/13.