Skip to content

Commit 94c1215

Browse files
committed
Add @mbabker's example in
1 parent 7766325 commit 94c1215

File tree

1 file changed

+11
-1
lines changed
  • manual/en-US/coding-standards/chapters

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,23 @@ $ref1 = &$this->sql;
146146
> In PHP 5, reference operators are not required for objects. All objects are handled by reference.
147147
148148
## Concatenation Spacing
149-
There should always be a space between two objects for example
149+
There should always be a space before and after the concatenation operator ('.'). For example:
150150

151151
```php
152152
$id = 1;
153153
echo JRoute('index.php?option=com_foo&task=foo.edit&id=' . (int) $id);
154154
```
155155

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+
156166
## Arrays
157167

158168
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)