From e5793f134c73dc87003b750a730a57c57edc8c4c Mon Sep 17 00:00:00 2001 From: lpd-au Date: Sun, 30 Nov 2025 13:25:53 +1100 Subject: [PATCH 1/3] Mention pipe operator --- spec.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/spec.md b/spec.md index 3024da5..19660c2 100644 --- a/spec.md +++ b/spec.md @@ -1292,9 +1292,11 @@ $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 – including [arithmetic][] (`** * / % + -`), [comparison][] + (`< <= > >= == != === !== <> <=>`), [assignment][] (`= += -= *= **= /= .= %= &= + |= ^= <<= >>= ??=`), [bitwise][] (`<< >> & ^ |`), [logical][] (`&& || and xor +or`), [string][] (`.`), [type][] (`instanceof`) and [functional][] (`|>`) +operators – MUST be preceded and followed by at least one space: ```php if ($a === $b) { @@ -1782,12 +1784,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 From 1c12e559edf02fcfb15fef4729391c17fa8dedcb Mon Sep 17 00:00:00 2001 From: lpd-au Date: Sun, 30 Nov 2025 13:36:30 +1100 Subject: [PATCH 2/3] Reorganise for clarity --- spec.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/spec.md b/spec.md index 19660c2..3a18ad4 100644 --- a/spec.md +++ b/spec.md @@ -1292,11 +1292,7 @@ $intValue = (int) $input; ### 6.2. Binary operators -All binary operators – including [arithmetic][] (`** * / % + -`), [comparison][] - (`< <= > >= == != === !== <> <=>`), [assignment][] (`= += -= *= **= /= .= %= &= - |= ^= <<= >>= ??=`), [bitwise][] (`<< >> & ^ |`), [logical][] (`&& || and xor -or`), [string][] (`.`), [type][] (`instanceof`) and [functional][] (`|>`) -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) { @@ -1306,6 +1302,17 @@ if ($a === $b) { } ``` +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 From 03416a493848d047fea14d498f6c135e610f9514 Mon Sep 17 00:00:00 2001 From: lpd-au Date: Sun, 30 Nov 2025 13:49:53 +1100 Subject: [PATCH 3/3] Include pipe examples --- spec.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec.md b/spec.md index 3a18ad4..c478084 100644 --- a/spec.md +++ b/spec.md @@ -1299,6 +1299,8 @@ if ($a === $b) { $foo = $bar ?? $a ?? $b; } elseif ($a > $b) { $foo = $a + $b * $c; +} else { + $foo = $a |> log(...) |> round(...); } ``` @@ -1350,6 +1352,10 @@ $variable2 = $possibleNullableExpr $variable3 = $elvisExpr ?: 'qix'; + +$variable4 = '' + |> strtoupper(...) + |> htmlspecialchars(...); ``` ## 7. Closures