-
Notifications
You must be signed in to change notification settings - Fork 709
PHP: 8.x keywords #2054
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
PHP: 8.x keywords #2054
Conversation
A full error message would be helpful. Which module raises |
Sorry, that was awful of me for not including the error message. I'm trying to execute the file directly. I don't know if this is the right thing to do or not.
|
Oh right, this is due to the |
OK, since there were a few more snags, I've updated the file in #2056 - can you check if it matches what you'd expect? |
@@ -221,7 +221,7 @@ class PhpLexer(RegexLexer): | |||
r'array|E_ALL|NULL|final|php_user_filter|interface|' | |||
r'implements|public|private|protected|abstract|clone|try|' | |||
r'catch|throw|this|use|namespace|trait|yield|' | |||
r'finally)\b', Keyword), | |||
r'finally|match)\b', Keyword), |
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.
I'm pretty sure readonly
is in the right place, however there's two places where switch
is defined (Keyword
and Keyword.Declaration
). Is there a way I can test this to make sure it works? Match works just like switch:
switch ($var) {
case 'a':
$result = "some value";
break;
case 'b':
$result = "some other value";
break;
}
// can be replaced with
$result = match ($var) {
'a' => "some value",
'b' => "some other value",
};
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.
I don't see the other place? In any case, this LGTM.
This is part of the work required to get PHP 8.x support in Pygments. There is something else that needs to be added onto this patch that I couldn't figure out.
The file
pygments/lexers/_php_builtins.py
needs to be regenerated as there are several new functions in the standard library, such asstr_starts_with
(8.0) andarray_is_list
(8.1). I tried to run it locally after installingrequirements.txt
with Pip, but I keep gettingModuleNotFoundError
. I'm not a Python developer, what do I need to do to get this to rebuild?