PHP: Added `never` return type + minor fix of named arguments (#3421)

This commit is contained in:
Tom Pavelec 2022-04-01 22:10:16 +02:00 committed by GitHub
parent 11c54624ee
commit 4ffab52597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 4 deletions

View File

@ -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|never|object|self|static|string|void)\b/i,
alias: 'return-type',
greedy: true,
lookbehind: true
@ -100,12 +100,12 @@
//
// keywords cannot be preceded by "->"
// the complex lookbehind means `(?<!(?:->|::)\s*)`
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,
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,
lookbehind: true
}
],
'argument-name': {
pattern: /([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,
pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
lookbehind: true
},
'class-name': [

File diff suppressed because one or more lines are too long

View File

@ -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", "("],

View File

@ -47,6 +47,7 @@ isset
list
namespace;
match
never
new;
or
parent
@ -71,6 +72,7 @@ try
unset
use;
var
void
while
xor
yield
@ -128,6 +130,7 @@ yield from
["keyword", "list"],
["keyword", "namespace"], ["punctuation", ";"],
["keyword", "match"],
["keyword", "never"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "or"],
["keyword", "parent"],
@ -152,6 +155,7 @@ yield from
["keyword", "unset"],
["keyword", "use"], ["punctuation", ";"],
["keyword", "var"],
["keyword", "void"],
["keyword", "while"],
["keyword", "xor"],
["keyword", "yield"],