diff --git a/components/prism-php.js b/components/prism-php.js index e11cd9cdea..3db55c2aad 100644 --- a/components/prism-php.js +++ b/components/prism-php.js @@ -48,6 +48,11 @@ lookbehind: true, alias: 'class-name' }, + 'function-definition': { + pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i, + lookbehind: true, + alias: 'function' + }, 'keyword': [ { pattern: /(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array)\b(?=\s*\))/i, @@ -95,7 +100,21 @@ alias: 'static-context', greedy: true }, - /\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i + { + // yield from + pattern: /(\byield\s+)from\b/i, + lookbehind: true + }, + // `class` is always a keyword unlike other keywords + /\bclass\b/i, + { + // https://www.php.net/manual/en/reserved.keywords.php + // + // keywords cannot be preceded by "->" + // the complex lookbehind means `(?|::)\s*)` + pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:__halt_compiler|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|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i, + lookbehind: true + } ], 'argument-name': { pattern: /([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i, @@ -200,9 +219,9 @@ } ], 'constant': constant, - 'function': /\w+\s*(?=\()/, + 'function': /\b\w+(?=\s*\()/, 'property': { - pattern: /(->)[\w]+/, + pattern: /(->\s*)\w+/, lookbehind: true }, 'number': number, @@ -243,7 +262,7 @@ 'punctuation': /^<<<"?|[";]$/ } }, - 'interpolation': string_interpolation // See below + 'interpolation': string_interpolation } }, { @@ -261,16 +280,13 @@ alias: 'double-quoted-string', greedy: true, inside: { - 'interpolation': string_interpolation // See below + 'interpolation': string_interpolation } } ]; Prism.languages.insertBefore('php', 'variable', { 'string': string, - }); - - Prism.languages.insertBefore('php', 'variable', { 'attribute': { pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/mi, greedy: true, @@ -316,7 +332,7 @@ }, }); - Prism.hooks.add('before-tokenize', function(env) { + Prism.hooks.add('before-tokenize', function (env) { if (!/<\?/.test(env.code)) { return; } @@ -325,7 +341,7 @@ Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern); }); - Prism.hooks.add('after-tokenize', function(env) { + Prism.hooks.add('after-tokenize', function (env) { Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php'); }); diff --git a/components/prism-php.min.js b/components/prism-php.min.js index c3b051295a..31a56ebb16 100644 --- a/components/prism-php.min.js +++ b/components/prism-php.min.js @@ -1 +1 @@ -!function(a){var e=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,t=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],i=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,n=/|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,s=/[{}\[\](),:;]/;a.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:e,variable:/\$+(?:\w+\b|(?={))/i,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},keyword:[{pattern:/(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:bool|int|float|string|object|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*[a-z0-9_|]\|\s*)(?:null|false)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?[a-z0-9_|]\|\s*)(?:null|false)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|iterable|(?:null|false)(?=\s*\|))\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:null|false)\b/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},/\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i],"argument-name":{pattern:/([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,function:/\w+\s*(?=\()/,property:{pattern:/(->)[\w]+/,lookbehind:!0},number:i,operator:n,punctuation:s};var l={pattern:/{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)*)/,lookbehind:!0,inside:a.languages.php},r=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:l}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:l}}];a.languages.insertBefore("php","variable",{string:r}),a.languages.insertBefore("php","variable",{attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=]$)/,lookbehind:!0,inside:{comment:e,string:r,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,number:i,operator:n,punctuation:s}},delimiter:{pattern:/^#\[|]$/,alias:"punctuation"}}}}),a.hooks.add("before-tokenize",function(e){if(/<\?/.test(e.code)){a.languages["markup-templating"].buildPlaceholders(e,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/gi)}}),a.hooks.add("after-tokenize",function(e){a.languages["markup-templating"].tokenizePlaceholders(e,"php")})}(Prism); \ No newline at end of file +!function(a){var e=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,t=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],i=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,n=/|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,s=/[{}\[\](),:;]/;a.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:e,variable:/\$+(?:\w+\b|(?={))/i,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:bool|int|float|string|object|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*[a-z0-9_|]\|\s*)(?:null|false)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?[a-z0-9_|]\|\s*)(?:null|false)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|iterable|(?:null|false)(?=\s*\|))\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:null|false)\b/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:__halt_compiler|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|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,function:/\b\w+(?=\s*\()/,property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:i,operator:n,punctuation:s};var l={pattern:/{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)*)/,lookbehind:!0,inside:a.languages.php},r=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:l}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:l}}];a.languages.insertBefore("php","variable",{string:r,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=]$)/,lookbehind:!0,inside:{comment:e,string:r,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,number:i,operator:n,punctuation:s}},delimiter:{pattern:/^#\[|]$/,alias:"punctuation"}}}}),a.hooks.add("before-tokenize",function(e){if(/<\?/.test(e.code)){a.languages["markup-templating"].buildPlaceholders(e,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/gi)}}),a.hooks.add("after-tokenize",function(e){a.languages["markup-templating"].tokenizePlaceholders(e,"php")})}(Prism); \ No newline at end of file diff --git a/tests/languages/php/attribute_feature.test b/tests/languages/php/attribute_feature.test index 6ce9a187cd..a7c2956ae7 100644 --- a/tests/languages/php/attribute_feature.test +++ b/tests/languages/php/attribute_feature.test @@ -57,306 +57,325 @@ function main() {} ---------------------------------------------------- [ - ["comment", "// #[Foo]"], - "\r\n\r\n#", - ["punctuation", "["], - ["punctuation", "]"], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["comment", "// something ]"], - ["attribute-class-name", "Foo"], - ["punctuation", ","], - ["comment", "/* something\r\n\telse #[] */"], - ["attribute-class-name", "Bar"], - ["comment", "# shell comments aren't confusing at all in here"] - ]], - ["delimiter", "]"] - ]], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "Foo"], - ["punctuation", "("], - ["punctuation", "["], - ["number", "0"], - ["punctuation", ","], - ["number", "1"], - ["punctuation", "]"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "Foo"], - ["punctuation", "("], - ["punctuation", "["], - ["number", "1"], - ["operator", "=>"], - ["punctuation", "["], - ["number", "0"], - ["punctuation", ","], - ["number", "1"], - ["punctuation", "]"], - ["punctuation", ","], - ["number", "2"], - ["operator", "=>"], - ["punctuation", "["], - ["number", "2"], - ["punctuation", ","], - ["number", "3"], - ["punctuation", "]"], - ["punctuation", ","], - ["number", "3"], - ["operator", "=>"], - ["punctuation", "["], - ["punctuation", "["], - ["number", "0"], - ["punctuation", ","], - ["number", "1"], - ["punctuation", "]"], - ["punctuation", ","], - ["punctuation", "["], - ["number", "2"], - ["punctuation", ","], - ["number", "3"], - ["punctuation", "]"], - ["punctuation", "]"], - ["punctuation", "]"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "Foo"] - ]], - ["delimiter", "]"] - ]], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", [ - "Foo", - ["punctuation", "\\"], - "Bar", - ["punctuation", "\\"], - "Baz" - ]] - ]], - ["delimiter", "]"] - ]], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "Route"], - ["punctuation", "("], - ["attribute-class-name", "Http"], - ["operator", "::"], - ["constant", "POST"], - ["punctuation", ","], - ["string", "'/products/create'"], - ["punctuation", ","], - ["number", "1"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", [ - "Http", - ["punctuation", "\\"], - "Route" - ]], - ["punctuation", "("], - ["attribute-class-name", "Http"], - ["operator", "::"], - ["constant", "POST"], - ["punctuation", ","], - ["string", "'/products/create'"], - ["punctuation", ","], - ["number", "1"], - ["punctuation", ")"], - ["punctuation", ","], - ["attribute-class-name", [ - "Foo", - ["punctuation", "\\"], - "Bar", - ["punctuation", "\\"], - "Baz" - ]], - ["punctuation", ","], - ["attribute-class-name", "AttributeFoo"], - ["punctuation", "("], - ["string", "'value'"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A1"], - ["punctuation", "("], - ["number", "1"], - ["punctuation", ")"], - ["punctuation", ","], - ["attribute-class-name", "A1"], - ["punctuation", "("], - ["number", "2"], - ["punctuation", ")"], - ["punctuation", ","], - ["attribute-class-name", "A2"], - ["punctuation", "("], - ["number", "3"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["keyword", "class"], - ["class-name-definition", "Foo"], - ["punctuation", "{"], - ["keyword", "public"], - ["keyword", "function"], - ["function", "foo"], - ["punctuation", "("], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A1"], - ["punctuation", "("], - ["number", "5"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["variable", "$a"], - ["punctuation", ","], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A1"], - ["punctuation", "("], - ["number", "6"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["variable", "$b"], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - ["punctuation", "}"], - - ["variable", "$object"], - ["operator", "="], - ["keyword", "new"], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A1"], - ["punctuation", "("], - ["number", "7"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["keyword", "class"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - ["punctuation", ";"], - - ["keyword", "function"], - ["function", "foo"], - ["punctuation", "("], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "Attribute"] - ]], - ["delimiter", "]"] - ]], - ["variable", "$param1"], - ["punctuation", ","], - ["variable", "$param2"], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["variable", "$f1"], - ["operator", "="], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "ExampleAttribute"] - ]], - ["delimiter", "]"] - ]], - ["keyword", "function"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - ["punctuation", ";"], - - ["variable", "$ref"], - ["operator", "="], - ["keyword", "new"], - ["class-name", [ - ["punctuation", "\\"], - "ReflectionFunction" - ]], - ["punctuation", "("], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A1"] - ]], - ["delimiter", "]"] - ]], - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "A2"] - ]], - ["delimiter", "]"] - ]], - ["keyword", "function"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - ["punctuation", ")"], - ["punctuation", ";"], - - ["attribute", [ - ["delimiter", "#["], - ["attribute-content", [ - ["attribute-class-name", "DeprecationReason"], - ["punctuation", "("], - ["string", "'reason: '"], - ["punctuation", ")"] - ]], - ["delimiter", "]"] - ]], - ["keyword", "function"], - ["function", "main"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"] + ["comment", "// #[Foo]"], + + "\r\n\r\n#", ["punctuation", "["], ["punctuation", "]"], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["comment", "// something ]"], + ["attribute-class-name", "Foo"], ["punctuation", ","], + ["comment", "/* something\r\n\telse #[] */"], + ["attribute-class-name", "Bar"], + ["comment", "# shell comments aren't confusing at all in here"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "Foo"], + ["punctuation", "("], + ["punctuation", "["], + ["number", "0"], + ["punctuation", ","], + ["number", "1"], + ["punctuation", "]"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "Foo"], + ["punctuation", "("], + + ["punctuation", "["], + + ["number", "1"], + ["operator", "=>"], + ["punctuation", "["], + ["number", "0"], + ["punctuation", ","], + ["number", "1"], + ["punctuation", "]"], + ["punctuation", ","], + + ["number", "2"], + ["operator", "=>"], + ["punctuation", "["], + ["number", "2"], + ["punctuation", ","], + ["number", "3"], + ["punctuation", "]"], + ["punctuation", ","], + + ["number", "3"], + ["operator", "=>"], + ["punctuation", "["], + + ["punctuation", "["], + ["number", "0"], + ["punctuation", ","], + ["number", "1"], + ["punctuation", "]"], + ["punctuation", ","], + + ["punctuation", "["], + ["number", "2"], + ["punctuation", ","], + ["number", "3"], + ["punctuation", "]"], + + ["punctuation", "]"], + + ["punctuation", "]"], + + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "Foo"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", [ + "Foo", + ["punctuation", "\\"], + "Bar", + ["punctuation", "\\"], + "Baz" + ]] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "Route"], + ["punctuation", "("], + ["attribute-class-name", "Http"], + ["operator", "::"], + ["constant", "POST"], + ["punctuation", ","], + ["string", "'/products/create'"], + ["punctuation", ","], + ["number", "1"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", [ + "Http", + ["punctuation", "\\"], + "Route" + ]], + ["punctuation", "("], + ["attribute-class-name", "Http"], + ["operator", "::"], + ["constant", "POST"], + ["punctuation", ","], + ["string", "'/products/create'"], + ["punctuation", ","], + ["number", "1"], + ["punctuation", ")"], + ["punctuation", ","], + + ["attribute-class-name", [ + "Foo", + ["punctuation", "\\"], + "Bar", + ["punctuation", "\\"], + "Baz" + ]], + ["punctuation", ","], + + ["attribute-class-name", "AttributeFoo"], + ["punctuation", "("], + ["string", "'value'"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A1"], + ["punctuation", "("], + ["number", "1"], + ["punctuation", ")"], + ["punctuation", ","], + ["attribute-class-name", "A1"], + ["punctuation", "("], + ["number", "2"], + ["punctuation", ")"], + ["punctuation", ","], + ["attribute-class-name", "A2"], + ["punctuation", "("], + ["number", "3"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["keyword", "class"], + ["class-name-definition", "Foo"], + ["punctuation", "{"], + + ["keyword", "public"], + ["keyword", "function"], + ["function-definition", "foo"], + ["punctuation", "("], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A1"], + ["punctuation", "("], + ["number", "5"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + ["variable", "$a"], + ["punctuation", ","], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A1"], + ["punctuation", "("], + ["number", "6"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + ["variable", "$b"], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["punctuation", "}"], + + ["variable", "$object"], + ["operator", "="], + ["keyword", "new"], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A1"], + ["punctuation", "("], + ["number", "7"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + ["keyword", "class"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + + ["keyword", "function"], + ["function-definition", "foo"], + ["punctuation", "("], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "Attribute"] + ]], + ["delimiter", "]"] + ]], + ["variable", "$param1"], + ["punctuation", ","], + + ["variable", "$param2"], + + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["variable", "$f1"], + ["operator", "="], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "ExampleAttribute"] + ]], + ["delimiter", "]"] + ]], + ["keyword", "function"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + + ["variable", "$ref"], + ["operator", "="], + ["keyword", "new"], + ["class-name", [ + ["punctuation", "\\"], + "ReflectionFunction" + ]], + ["punctuation", "("], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A1"] + ]], + ["delimiter", "]"] + ]], + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "A2"] + ]], + ["delimiter", "]"] + ]], + ["keyword", "function"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ")"], + ["punctuation", ";"], + + ["attribute", [ + ["delimiter", "#["], + ["attribute-content", [ + ["attribute-class-name", "DeprecationReason"], + ["punctuation", "("], + ["string", "'reason: '"], + ["punctuation", ")"] + ]], + ["delimiter", "]"] + ]], + + ["keyword", "function"], + ["function-definition", "main"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/php/class-name_feature.test b/tests/languages/php/class-name_feature.test index bf3502ae6e..09f5432e7a 100644 --- a/tests/languages/php/class-name_feature.test +++ b/tests/languages/php/class-name_feature.test @@ -60,7 +60,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", ";"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["class-name", "Foo"], ["variable", "$variable"], @@ -71,7 +71,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", "}"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["class-name", [ ["punctuation", "\\"], @@ -88,7 +88,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", "}"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["class-name", [ ["punctuation", "\\"], @@ -109,7 +109,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", "}"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["variable", "$variable"], ["punctuation", ")"], @@ -120,7 +120,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", "}"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["class-name", "Foo"], ["operator", "|"], @@ -135,7 +135,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["punctuation", "}"], ["keyword", "function"], - ["function", "f"], + ["function-definition", "f"], ["punctuation", "("], ["class-name", [ ["punctuation", "\\"], diff --git a/tests/languages/php/delimiter_feature.test b/tests/languages/php/delimiter_feature.test index 22e613f835..506214ded5 100644 --- a/tests/languages/php/delimiter_feature.test +++ b/tests/languages/php/delimiter_feature.test @@ -27,6 +27,7 @@ function main() {} ["php", [ ["delimiter", ""] + + ["delimiter", "?>"] ]] ] diff --git a/tests/languages/php/function_feature.test b/tests/languages/php/function_feature.test new file mode 100644 index 0000000000..d04d07d985 --- /dev/null +++ b/tests/languages/php/function_feature.test @@ -0,0 +1,136 @@ +class A { + function __call() {} +} + +$a = new A(); +$a->if(); // it's allowed to call a magic method with keyword since forever in PHP + +class A { + function if() {} // error before 7.0, allowed now +} + +$variable->foreach(); // this "foreach" is a method +$variable->method(); // this is also a method +$var->match() + +foreach ($list as $value) { // this "foreach" is a keyword +} + +Test::foreach(); // this is "foreach" static method +Test::method(); // this is "method" static method + +// The only exception: class +$variable->class(); // this "class" should be interpreted as "keyword" +Test::class; // This "class" should still be a keyword + +---------------------------------------------------- + +[ + ["keyword", "class"], + ["class-name-definition", "A"], + ["punctuation", "{"], + + ["keyword", "function"], + ["function-definition", "__call"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["punctuation", "}"], + + ["variable", "$a"], + ["operator", "="], + ["keyword", "new"], + ["class-name", "A"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + + ["variable", "$a"], + ["operator", "->"], + ["function", "if"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// it's allowed to call a magic method with keyword since forever in PHP"], + + ["keyword", "class"], + ["class-name-definition", "A"], + ["punctuation", "{"], + + ["keyword", "function"], + ["function-definition", "if"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["comment", "// error before 7.0, allowed now"], + + ["punctuation", "}"], + + ["variable", "$variable"], + ["operator", "->"], + ["function", "foreach"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// this \"foreach\" is a method"], + + ["variable", "$variable"], + ["operator", "->"], + ["function", "method"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// this is also a method"], + + ["variable", "$var"], + ["operator", "->"], + ["function", "match"], + ["punctuation", "("], + ["punctuation", ")"], + + ["keyword", "foreach"], + ["punctuation", "("], + ["variable", "$list"], + ["keyword", "as"], + ["variable", "$value"], + ["punctuation", ")"], + ["punctuation", "{"], + ["comment", "// this \"foreach\" is a keyword"], + + ["punctuation", "}"], + + ["class-name", "Test"], + ["operator", "::"], + ["function", "foreach"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// this is \"foreach\" static method"], + + ["class-name", "Test"], + ["operator", "::"], + ["function", "method"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// this is \"method\" static method"], + + ["comment", "// The only exception: class"], + + ["variable", "$variable"], + ["operator", "->"], + ["keyword", "class"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// this \"class\" should be interpreted as \"keyword\""], + + ["class-name", "Test"], + ["operator", "::"], + ["keyword", "class"], + ["punctuation", ";"], + ["comment", "// This \"class\" should still be a keyword"] +] \ No newline at end of file diff --git a/tests/languages/php/keyword_feature.test b/tests/languages/php/keyword_feature.test index 88d5e2bbbc..0c4789f3b2 100644 --- a/tests/languages/php/keyword_feature.test +++ b/tests/languages/php/keyword_feature.test @@ -49,7 +49,7 @@ match new; or parent -parent:: +parent::; print private protected @@ -59,9 +59,9 @@ require_once return self new self -self:: +self::; static -static:: +static::; switch throw trait; @@ -72,6 +72,7 @@ var while xor yield +yield from ---------------------------------------------------- @@ -127,7 +128,7 @@ yield ["keyword", "new"], ["punctuation", ";"], ["keyword", "or"], ["keyword", "parent"], - ["keyword", "parent"], ["operator", "::"], + ["keyword", "parent"], ["operator", "::"], ["punctuation", ";"], ["keyword", "print"], ["keyword", "private"], ["keyword", "protected"], @@ -137,9 +138,9 @@ yield ["keyword", "return"], ["keyword", "self"], ["keyword", "new"], ["keyword", "self"], - ["keyword", "self"], ["operator", "::"], + ["keyword", "self"], ["operator", "::"], ["punctuation", ";"], ["keyword", "static"], - ["keyword", "static"], ["operator", "::"], + ["keyword", "static"], ["operator", "::"], ["punctuation", ";"], ["keyword", "switch"], ["keyword", "throw"], ["keyword", "trait"], ["punctuation", ";"], @@ -149,9 +150,10 @@ yield ["keyword", "var"], ["keyword", "while"], ["keyword", "xor"], - ["keyword", "yield"] + ["keyword", "yield"], + ["keyword", "yield"], ["keyword", "from"] ] ---------------------------------------------------- -Checks for comments. \ No newline at end of file +Checks for keywords. diff --git a/tests/languages/php/type_feature.test b/tests/languages/php/type_feature.test index 196110b445..eab7dc1ad3 100644 --- a/tests/languages/php/type_feature.test +++ b/tests/languages/php/type_feature.test @@ -30,45 +30,207 @@ function foo(int $a, string $b, ? object $c, ?array $d, self $e, static $f, int ---------------------------------------------------- [ - ["keyword", "public"], ["keyword", "bool"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "int"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "float"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "string"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "object"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "array"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "mixed"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "int"], ["operator", "|"], ["keyword", "null"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "int"], ["operator", "|"], ["keyword", "false"], ["variable", "$a"], ["punctuation", ";"], - ["keyword", "public"], ["keyword", "false"], ["operator", "|"], ["keyword", "int"], ["variable", "$a"], ["punctuation", ";"], - - ["punctuation", "("], ["keyword", "int"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - ["punctuation", "("], ["keyword", "string"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - ["punctuation", "("], ["keyword", "object"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - ["punctuation", "("], ["keyword", "array"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - ["punctuation", "("], ["keyword", "boolean"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - ["punctuation", "("], ["keyword", "integer"], ["punctuation", ")"], ["variable", "$a"], ["punctuation", ";"], - - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "int"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "string"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "object"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["operator", "?"], ["keyword", "array"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "self"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "static"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "int"], ["operator", "|"], ["keyword", "null"], ["punctuation", "{"], ["punctuation", "}"], - ["keyword", "function"], ["function", "f"], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ":"], ["keyword", "int"], ["operator", "|"], ["keyword", "false"], ["punctuation", "{"], ["punctuation", "}"], - - ["keyword", "function"], ["function", "foo"], ["punctuation", "("], - ["keyword", "int"], ["variable", "$a"], ["punctuation", ","], - ["keyword", "string"], ["variable", "$b"], ["punctuation", ","], - ["operator", "?"], ["keyword", "object"], ["variable", "$c"], ["punctuation", ","], - ["operator", "?"], ["keyword", "array"], ["variable", "$d"], ["punctuation", ","], - ["keyword", "self"], ["variable", "$e"], ["punctuation", ","], - ["keyword", "static"], ["variable", "$f"], ["punctuation", ","], - ["keyword", "int"], ["operator", "|"], ["keyword", "null"], ["variable", "$g"], + ["keyword", "public"], + ["keyword", "bool"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "int"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "float"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "string"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "object"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "array"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "mixed"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "int"], + ["operator", "|"], + ["keyword", "null"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "int"], + ["operator", "|"], + ["keyword", "false"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "public"], + ["keyword", "false"], + ["operator", "|"], + ["keyword", "int"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "int"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "string"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "object"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "array"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "boolean"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["punctuation", "("], + ["keyword", "integer"], + ["punctuation", ")"], + ["variable", "$a"], + ["punctuation", ";"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "string"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "object"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["operator", "?"], + ["keyword", "array"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "self"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "static"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "int"], + ["operator", "|"], + ["keyword", "null"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "f"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ":"], + ["keyword", "int"], + ["operator", "|"], + ["keyword", "false"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "function"], + ["function-definition", "foo"], + ["punctuation", "("], + ["keyword", "int"], + ["variable", "$a"], + ["punctuation", ","], + ["keyword", "string"], + ["variable", "$b"], + ["punctuation", ","], + ["operator", "?"], + ["keyword", "object"], + ["variable", "$c"], + ["punctuation", ","], + ["operator", "?"], + ["keyword", "array"], + ["variable", "$d"], + ["punctuation", ","], + ["keyword", "self"], + ["variable", "$e"], + ["punctuation", ","], + ["keyword", "static"], + ["variable", "$f"], + ["punctuation", ","], + ["keyword", "int"], + ["operator", "|"], + ["keyword", "null"], + ["variable", "$g"], ["punctuation", ")"], - ["punctuation", "{"], ["punctuation", "}"] + ["punctuation", "{"], + ["punctuation", "}"] ] ---------------------------------------------------- -Checks for types. \ No newline at end of file +Checks for types.