Permalink
Browse files

feature #4457 [RFC] Clarification on formatting for bangs (!) (bryana…

…gee)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #4457).

Discussion
----------

[RFC] Clarification on formatting for bangs (!)

It seems to me that
> Add a single space around operators

would mean using the practice on the bang operator as well; as discussed in [this thread](https://github.com/php-fig/fig-standards/issues/102), there is somewhat of a conflict--so this may not be the way to go. If the PSR could be amended, then this change would make sense.

Commits
-------

ee888c6 Fixes concat operator typo
33e76a5 Incorporates @wouterj 's suggestion for more realistic usage of bang
837e895 Changes operator spacing language
835d5eb Adds missing space before return statement
3799bc0 Fixes spelling and formatting errors
30d19ab Fixes wrong bullet character
3212b6c Adds bullet addressing bang placement
95a1cc5 Reverses statement about bang spacing and corresponding examples
a68d3e5 [RFC] Clarification on formatting for bangs (!)
  • Loading branch information...
weaverryan committed Dec 6, 2014
2 parents 0a9c146 + ee888c6 commit 8bba31667333f654349f151e116593a9580c1c46
Showing with 13 additions and 1 deletion.
  1. +13 −1 contributing/code/standards.rst
@@ -79,14 +79,26 @@ example containing most features described below:
throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
}
private function reverseBoolean($value = null, $theSwitch = false)
{
if (!$theSwitch) {
return;
}
return !$value;
}
}
Structure
---------
* Add a single space after each comma delimiter;
* Add a single space around operators (``==``, ``&&``, ...);
* Add a single space around binary operators (``==``, ``&&``, ...), with
the exception of the concatenation (``.``) operator;
* Place unary operators (``!``, ``--``, ...) adjacent to the affected variable;
* Add a comma after each array item in a multi-line array, even after the
last one;

1 comment on commit 8bba316

@ywarnier

This comment has been minimized.

ywarnier commented on 8bba316 Apr 3, 2017

Excuse me for my love of details, but I think you should use a stricter formula to explain what you expect.

Add a single space around binary operators (``==``, ``&&``, ...), with the exception of the concatenation (``.``) operator;

Should be

Add a single space around binary operators (``==``, ``&&``, ...). The concatenation (``.``) operator is an exception and cannot be surrounded by spaces;

Otherwise you still leave the door open to interpreting it as "with the concatenation operator, do what you want.". The terminology of PSR is very well chosen to avoid this kind of confusion.

Please sign in to comment.