Skip to content

Commit 556857e

Browse files
committed
Merge pull request joomla#75 from wilsonge/patch-1
Add note about Concatenation spacing
2 parents 0740954 + 94c1215 commit 556857e

File tree

1 file changed

+18
-0
lines changed
  • manual/en-US/coding-standards/chapters

1 file changed

+18
-0
lines changed

manual/en-US/coding-standards/chapters/php.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,24 @@ $ref1 = &$this->sql;
145145
>
146146
> In PHP 5, reference operators are not required for objects. All objects are handled by reference.
147147
148+
## Concatenation Spacing
149+
There should always be a space before and after the concatenation operator ('.'). For example:
150+
151+
```php
152+
$id = 1;
153+
echo JRoute('index.php?option=com_foo&task=foo.edit&id=' . (int) $id);
154+
```
155+
156+
If the concatenation operator is the first or last character on a line, both spaces are not required. For example:
157+
158+
```php
159+
$id = 1
160+
echo JRoute::_(
161+
'index.php?option=com_foo&task=foo.edit&id=' . (int) $id
162+
. '&layout=special'
163+
);
164+
```
165+
148166
## Arrays
149167

150168
Assignments (the `=>` operator) in arrays may be aligned with tabs. When splitting array definitions onto several lines, the last value may also have a trailing comma. This is valid PHP syntax and helps to keep code diffs minimal.

0 commit comments

Comments
 (0)