Skip to content

Commit ee62a08

Browse files
PHP: Removed useless keyword tokens (#3121)
1 parent dc1e808 commit ee62a08

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

components/prism-php.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,19 @@
6666
greedy: true,
6767
lookbehind: true
6868
},
69-
{
70-
pattern: /([(,?]\s*[\w|]\|\s*)(?:false|null)\b(?=\s*\$)/i,
71-
alias: 'type-hint',
72-
greedy: true,
73-
lookbehind: true
74-
},
7569
{
7670
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string|void)\b/i,
7771
alias: 'return-type',
7872
greedy: true,
7973
lookbehind: true
8074
},
8175
{
82-
pattern: /(\)\s*:\s*(?:\?\s*)?[\w|]\|\s*)(?:false|null)\b/i,
83-
alias: 'return-type',
84-
greedy: true,
85-
lookbehind: true
86-
},
87-
{
88-
pattern: /\b(?:array(?!\s*\()|bool|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|string|void)\b/i,
76+
pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
8977
alias: 'type-declaration',
9078
greedy: true
9179
},
9280
{
93-
pattern: /(\|\s*)(?:false|null)\b/i,
81+
pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
9482
alias: 'type-declaration',
9583
greedy: true,
9684
lookbehind: true

components/prism-php.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/php/class-name_feature.test

+33
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ function f($variable): ?Foo {}
1616

1717
function f(Foo|Bar $variable): Foo|Bar {}
1818

19+
function f(Foo|false $variable): Foo|Bar {}
20+
function f(Foo|null $variable): Foo|Bar {}
21+
1922
function f(\Package\Foo|\Package\Bar $variable): \Package\Foo|\Package\Bar {}
2023

2124
class Foo extends Bar implements Baz {}
@@ -134,6 +137,36 @@ class Foo extends \Package\Bar implements App\Baz {}
134137
["punctuation", "{"],
135138
["punctuation", "}"],
136139

140+
["keyword", "function"],
141+
["function-definition", "f"],
142+
["punctuation", "("],
143+
["class-name", "Foo"],
144+
["operator", "|"],
145+
["keyword", "false"],
146+
["variable", "$variable"],
147+
["punctuation", ")"],
148+
["punctuation", ":"],
149+
["class-name", "Foo"],
150+
["operator", "|"],
151+
["class-name", "Bar"],
152+
["punctuation", "{"],
153+
["punctuation", "}"],
154+
155+
["keyword", "function"],
156+
["function-definition", "f"],
157+
["punctuation", "("],
158+
["class-name", "Foo"],
159+
["operator", "|"],
160+
["keyword", "null"],
161+
["variable", "$variable"],
162+
["punctuation", ")"],
163+
["punctuation", ":"],
164+
["class-name", "Foo"],
165+
["operator", "|"],
166+
["class-name", "Bar"],
167+
["punctuation", "{"],
168+
["punctuation", "}"],
169+
137170
["keyword", "function"],
138171
["function-definition", "f"],
139172
["punctuation", "("],

0 commit comments

Comments
 (0)