Skip to content

Commit

Permalink
PHP: added 'never' return type + minor fix of named arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPavelec committed Apr 1, 2022
1 parent 11c5462 commit d3d92a2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/prism-php.js
Expand Up @@ -67,7 +67,7 @@
lookbehind: true
},
{
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string|void)\b/i,
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string|void|never)\b/i,
alias: 'return-type',
greedy: true,
lookbehind: true
Expand Down Expand Up @@ -105,7 +105,7 @@
}
],
'argument-name': {
pattern: /([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,
pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
lookbehind: true
},
'class-name': [
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tests/languages/php/argument-name_feature.test
Expand Up @@ -3,9 +3,27 @@ foo(
qux: 'baz'
);

foo(a: 'bar', qux: 'baz' );

----------------------------------------------------

[
["function", ["foo"]],
["punctuation", "("],

["argument-name", "a"],
["punctuation", ":"],
["string", "'bar'"],
["punctuation", ","],

["argument-name", "qux"],
["punctuation", ":"],
["string", "'baz'"],

["punctuation", ")"],
["punctuation", ";"],


["function", ["foo"]],
["punctuation", "("],

Expand Down
4 changes: 4 additions & 0 deletions tests/languages/php/keyword_feature.test
Expand Up @@ -47,6 +47,7 @@ isset
list
namespace;
match
never
new;
or
parent
Expand All @@ -71,6 +72,7 @@ try
unset
use;
var
void
while
xor
yield
Expand Down Expand Up @@ -128,6 +130,7 @@ yield from
["keyword", "list"],
["keyword", "namespace"], ["punctuation", ";"],
["keyword", "match"],
["keyword", "never"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "or"],
["keyword", "parent"],
Expand All @@ -152,6 +155,7 @@ yield from
["keyword", "unset"],
["keyword", "use"], ["punctuation", ";"],
["keyword", "var"],
["keyword", "void"],
["keyword", "while"],
["keyword", "xor"],
["keyword", "yield"],
Expand Down

0 comments on commit d3d92a2

Please sign in to comment.