-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enh(php) support C style and hash prefix single line comments in functions #4230
base: main
Are you sure you want to change the base?
Conversation
Looks like the single lines PHP comments that starts with |
80f3fa7
to
6060d5c
Compare
@@ -49,3 +49,15 @@ setAlarm( | |||
label: 'foo', | |||
time:time() + array(5)[0] + Foo::HOUR, | |||
); | |||
|
|||
header( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is header a PHP thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this context (functions.txt), he calling user definer function:
header()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is header a PHP thing?
Yes! That is used to add a HTTP response header to the output. PHP is pretty much a language to generate web pages and their responses and header()
is I guess known to anyone practicing PHP. https://www.php.net/manual/en/function.header.php
The function name should not matter to highlight.js, as long as it is recognized as a function. If header()
is confusing, I do not mind changing it to another built-in function that is common to other languages such as printf()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an entry to CHANGES.md as well! Looks good!
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +16 B View Changes
|
functions, arrow functions parameters can contain nested comments such as: header( /* cache age */ 'Age: 60' ); fn($x /* something */) => $x; Those are C blocks comments. However PHP also support single line comments either C-style (`//`) or using hash (`#`): header( # Set caching header 'Age: 60' // seconds ); fn( # We like magic $x // something ) => $x; PHP 8 attributes can also have such comments: #[\Deprecated( # A comment since: "2025-03-25" // C line comment #)] Parameters of functions, arrow functions and PHP 8 attributes solely had `C_BLOCK_COMMENT_MODE`. Add `C_LINE_COMMENT_MODE` and `HASH_COMMENT_MODE` to recognize the single line comments. Fixes: highlightjs#3655 Fixes: https://phabricator.wikimedia.org/T372404
6060d5c
to
7a6a1f2
Compare
I have made adjustments to properly support attributes, thanks to @wkania
I have added an entry in the change log, thank you! |
enh(php) add // and # comments in functions and attributes
functions, arrow functions parameters can contain nested comments such as:
Those are C blocks comments. However PHP also support single line comments either C-style (
//
) or using hash (#
):PHP 8 attributes can also have such comments:
Parameters of functions, arrow functions and PHP 8 attributes solely had
C_BLOCK_COMMENT_MODE
.Add
C_LINE_COMMENT_MODE
andHASH_COMMENT_MODE
to recognize the single line comments.Fixes: #3655
Fixes: https://phabricator.wikimedia.org/T372404