Skip to content

Commit 4ffab52

Browse files
authored
PHP: Added never return type + minor fix of named arguments (#3421)
1 parent 11c5462 commit 4ffab52

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

components/prism-php.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
lookbehind: true
6868
},
6969
{
70-
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string|void)\b/i,
70+
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
7171
alias: 'return-type',
7272
greedy: true,
7373
lookbehind: true
@@ -100,12 +100,12 @@
100100
//
101101
// keywords cannot be preceded by "->"
102102
// the complex lookbehind means `(?<!(?:->|::)\s*)`
103-
pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
103+
pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
104104
lookbehind: true
105105
}
106106
],
107107
'argument-name': {
108-
pattern: /([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,
108+
pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
109109
lookbehind: true
110110
},
111111
'class-name': [

components/prism-php.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/php/argument-name_feature.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@ foo(
33
qux: 'baz'
44
);
55

6+
foo(a: 'bar', qux: 'baz' );
7+
68
----------------------------------------------------
79

810
[
11+
["function", ["foo"]],
12+
["punctuation", "("],
13+
14+
["argument-name", "a"],
15+
["punctuation", ":"],
16+
["string", "'bar'"],
17+
["punctuation", ","],
18+
19+
["argument-name", "qux"],
20+
["punctuation", ":"],
21+
["string", "'baz'"],
22+
23+
["punctuation", ")"],
24+
["punctuation", ";"],
25+
26+
927
["function", ["foo"]],
1028
["punctuation", "("],
1129

tests/languages/php/keyword_feature.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ isset
4747
list
4848
namespace;
4949
match
50+
never
5051
new;
5152
or
5253
parent
@@ -71,6 +72,7 @@ try
7172
unset
7273
use;
7374
var
75+
void
7476
while
7577
xor
7678
yield
@@ -128,6 +130,7 @@ yield from
128130
["keyword", "list"],
129131
["keyword", "namespace"], ["punctuation", ";"],
130132
["keyword", "match"],
133+
["keyword", "never"],
131134
["keyword", "new"], ["punctuation", ";"],
132135
["keyword", "or"],
133136
["keyword", "parent"],
@@ -152,6 +155,7 @@ yield from
152155
["keyword", "unset"],
153156
["keyword", "use"], ["punctuation", ";"],
154157
["keyword", "var"],
158+
["keyword", "void"],
155159
["keyword", "while"],
156160
["keyword", "xor"],
157161
["keyword", "yield"],

0 commit comments

Comments
 (0)