Skip to content

Commit 3e7d01a

Browse files
authored
Add preconisation for double parenthesis (#39)
1 parent a5d464b commit 3e7d01a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/style.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,38 @@ interface ExampleDomainAccessInterface
183183
}
184184
```
185185

186+
### Parenthesis
187+
188+
Never use double parenthesis like '((/* something */))'
189+
190+
```php
191+
# Valid
192+
$firstCondition = true;
193+
$secondCondition = false;
194+
195+
// Simple condition
196+
if ($firstCondition) {
197+
// Do something
198+
}
199+
200+
// Example with Coalescing operator
201+
trim((string) ($data[0]['address'] ?? ''));
202+
203+
// Adding parenthesis is accepted if there is an operator between operand
204+
if (($firstCondition) && ($secondCondition)) {
205+
// Do something
206+
}
207+
208+
# Invalid
209+
// Simple condition
210+
if (($firstCondition)) {
211+
// Do something
212+
}
213+
214+
// Example with Coalescing operator
215+
trim(($data[0]['address'] ?? null));
216+
```
217+
186218
### Passing object by reference
187219
Objects are always passed by reference. Using '&' to request to pass it by reference can be confusing
188220

0 commit comments

Comments
 (0)