symfony/symfony — Issue #3135: Clarify Coding-Standard (concatenation operator)
Author: lazaridis-com
Created: 2012-01-17 13:20:37+00:00
State: open

However, within the sources codes (e.g. GeneratorBundle) I see that there is use of a non-spaced-dot.

A developer within sensio/SensioGeneratorBundle#93 suggested that the existent Coding Standard dictates this.

The written document (http://symfony.com/doc/2.0/contributing/code/standards.html) has the authority, and it states clearly:

"Add a single space around operators (==, &&, ...);"

__No exception is mentioned for the concatenation operator, thus the rule is valid for it, too.__

And this is of course good so, because an eye-pair which has read lots of OO code, get's terribly confused by such php-code.

Using spaces distinguishes __clearly__ the concatenation-operator-dot from the OO-dot found in other languages.

-

Zend, Doctrine, Drupal (excerpts and links above) use spaced-dot - this seems to be the (rational) standard within the php domain.

"Strings must be concatenated using the "." operator. A space must always be added before and after the "." operator to improve readability: "
http://framework.zend.com/manual/1.11/en/coding-standard.coding-style.html

"Strings may be concatenated using the "." operator. A space must always be added before and after the "." operator to improve readability:"
http://www.doctrine-project.org/documentation/manual/1_0/nl/coding-standards#coding-style:strings:string-concatenation

"Always use a space between the dot and the concatenated parts to improve readability."
http://drupal.org/coding-standards#concat

-

As a php project, the Symfony2 project should adopt this standard.

If the Symfony2 project insists on it's own standard subjecting the concatenation-operator (dot), then it should be clearly stated within the coding-standards document.