diff --git a/spec.md b/spec.md index 3024da5..c478084 100644 --- a/spec.md +++ b/spec.md @@ -1292,18 +1292,29 @@ $intValue = (int) $input; ### 6.2. Binary operators -All binary [arithmetic][], [comparison][], [assignment][], [bitwise][], -[logical][], [string][], and [type][] operators MUST be preceded and -followed by at least one space: +All binary operators MUST be preceded and followed by at least one space: ```php if ($a === $b) { $foo = $bar ?? $a ?? $b; } elseif ($a > $b) { $foo = $a + $b * $c; +} else { + $foo = $a |> log(...) |> round(...); } ``` +As of writing, this applies to: + +* `** * / % + -` [arithmetic][] operators +* `< <= > >= == != === !== <> <=>` [comparison][] operators +* `= += -= *= **= /= .= %= &= |= ^= <<= >>= ??=` [assignment][] operators +* `<< >> & ^ |` [bitwise][] operators +* `&& || and xor or` [logical][] operators +* `.` [string][] operator ("concatenation") +* `instanceof` [type][] operator +* `|>` [functional][] operator ("pipe") + ### 6.3. Ternary operators The conditional operator, also known simply as the ternary operator, MUST be @@ -1341,6 +1352,10 @@ $variable2 = $possibleNullableExpr $variable3 = $elvisExpr ?: 'qix'; + +$variable4 = '' + |> strtoupper(...) + |> htmlspecialchars(...); ``` ## 7. Closures @@ -1782,12 +1797,13 @@ class Demo [PSR-1]: https://www.php-fig.org/psr/psr-1/ [PSR-12]: https://www.php-fig.org/psr/psr-12/ -[keywords]: http://php.net/manual/en/reserved.keywords.php -[types]: http://php.net/manual/en/reserved.other-reserved-words.php -[arithmetic]: http://php.net/manual/en/language.operators.arithmetic.php -[assignment]: http://php.net/manual/en/language.operators.assignment.php -[comparison]: http://php.net/manual/en/language.operators.comparison.php -[bitwise]: http://php.net/manual/en/language.operators.bitwise.php -[logical]: http://php.net/manual/en/language.operators.logical.php -[string]: http://php.net/manual/en/language.operators.string.php -[type]: http://php.net/manual/en/language.operators.type.php +[keywords]: https://php.net/manual/en/reserved.keywords.php +[types]: https://php.net/manual/en/reserved.other-reserved-words.php +[arithmetic]: https://php.net/manual/en/language.operators.arithmetic.php +[assignment]: https://php.net/manual/en/language.operators.assignment.php +[comparison]: https://php.net/manual/en/language.operators.comparison.php +[bitwise]: https://php.net/manual/en/language.operators.bitwise.php +[logical]: https://php.net/manual/en/language.operators.logical.php +[string]: https://php.net/manual/en/language.operators.string.php +[type]: https://php.net/manual/en/language.operators.type.php +[functional]: https://php.net/manual/en/language.operators.functional.php