Add php-pipe-op face for the PHP 8.5 pipe operator#821
Merged
Conversation
The pipe operator came out half-fontified. No rule matched `|>', so
the comparison-operator matcher -- whose `[<>]=?' alternative claims a
bare `>' -- took the second character and left the first one plain:
'|' -> nil
'>' -> php-comparison-op
Give it a face of its own. php-pipe-op inherits php-operator like the
rest of the operator faces, and its rule sits ahead of the comparison
operators so it wins the `>'.
The rule is deliberately narrow (`|>' only), so nothing else moves:
`||', `>=', `>', `===', `<=>', `=>' and a bare `|' all keep the faces
they had. A test pins that down alongside the pipe itself.
See https://www.php.net/releases/8.5/en.php
zonuexe
added a commit
that referenced
this pull request
Jul 16, 2026
php-pipe-op and its rule arrived on master (#821) in the CC Mode based php-mode.el, which this branch renames to php-cc-mode.el; the new mode body needs the same rule for the same reason. Without it the comparison-operator matcher claims the `>' of `|>' and leaves the `|' plain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
PHP 8.5's pipe operator came out half-fontified. No rule matched
|>, so the comparison-operator matcher — whose[<>]=?alternative claims a bare>— took the second character and left the first one plain:So
|>rendered as an unstyled pipe followed by what looks like a comparison operator.The fix
php-pipe-opinheritsphp-operator, like every other operator face in php-face.el:Its font-lock rule sits ahead of the comparison operators so it wins the
>. The rule is deliberately narrow (|>only), so nothing else moves.Verification
Both characters now get the face, and the operators the new rule could have stolen from are unchanged:
|>php-pipe-opphp-pipe-op✅||php-logical-op×2 (unchanged)>=php-comparison-op×2 (unchanged)>php-comparison-op(unchanged)<=>php-comparison-op×3 (unchanged)|nil(unchanged)The test asserts faces directly rather than through a
.facesgolden file — golden files that contain doc comments are Emacs-version-sensitive here (hence the existing.24/.27variants), and this way the test states its intent and stays version-robust. Verified that it fails before the change ((nil php-comparison-op)) and passes after.Byte-compiles with no new warnings; full suite green, including every existing
.facesfixture.Note
This targets the v1.28 (CC Mode) series so both it and the cc-mode independent rewrite fontify the pipe the same way — the bug is identical in both engines, since they share this matcher. The matching rule for the new php-mode.el in #812 follows there.