Skip to content

Commit d91685c

Browse files
committed
Stop recommending and/or over &&/||
The coding guidelines suggest using `and` and `or` over `&&` and `||`. Frankly I don't think this is a good idea. The precedence rules for `and` and `or` are so weird, they will cause lots of confusion and edge cases. To illustrate this, look at the following example ([from logical operators][0]): $x = false or true; What do you expect the value of `$x` to be? It's `false`, because `or` has lower precedence than `=`. So while you expected the expression to be: $x = (false or true); It is in fact: ($x = false) or true; Stop using `and`/`or` as logical operators. They were designed for flow control. [0]: http://php.net/manual/en/language.operators.logical.php
1 parent 0aa723a commit d91685c

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

contributing.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ Laravel follows the [PSR-0](https://github.com/php-fig/fig-standards/blob/master
2828
- Namespace declarations should be on the same line as `<?php`.
2929
- Class opening `{` should be on the same line as the class name.
3030
- Function and control structure opening `{` should be on a separate line.
31-
- Always use `and` and `or`. Never use `&&` or `||`.
3231
- Interface names are suffixed with `Interface` (`FooInterface`)

0 commit comments

Comments
 (0)