From 87d79390645951be0174699d130e566e5ffa169c Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Mon, 17 May 2021 16:28:00 +0200 Subject: [PATCH] PHP: Fixed functions with namespaces (#2889) --- components/prism-php.js | 8 +- components/prism-php.min.js | 2 +- tests/languages/latte/delimiter_feature.test | 101 ++++++++++++++++-- .../languages/php!+css-extras/issue2008.test | 86 +++++++-------- .../php!+php-extras/scope_feature.test | 16 ++- .../languages/php/argument-name_feature.test | 7 +- tests/languages/php/class-name_feature.test | 6 +- tests/languages/php/function_feature.test | 50 +++++++-- .../php/string-interpolation_feature.test | 6 +- 9 files changed, 209 insertions(+), 73 deletions(-) diff --git a/components/prism-php.js b/components/prism-php.js index 970db8f333..02abdc8349 100644 --- a/components/prism-php.js +++ b/components/prism-php.js @@ -219,7 +219,13 @@ } ], 'constant': constant, - 'function': /\b\w+(?=\s*\()/, + 'function': { + pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i, + lookbehind: true, + inside: { + 'punctuation': /\\/ + } + }, 'property': { pattern: /(->\s*)\w+/, lookbehind: true diff --git a/components/prism-php.min.js b/components/prism-php.min.js index 9733bd4da1..906401a753 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"},"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|fn|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 +!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|fn|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:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},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/latte/delimiter_feature.test b/tests/languages/latte/delimiter_feature.test index 23d0bac34b..4116230304 100644 --- a/tests/languages/latte/delimiter_feature.test +++ b/tests/languages/latte/delimiter_feature.test @@ -14,17 +14,102 @@ line} ---------------------------------------------------- [ - ["latte", [["ld", [["punctuation", "{"], ["tag", "aa"]]], ["rd", [["punctuation", "}"]]]]], - ["latte", [["ld", [["punctuation", "{/"], ["tag", "aa"]]], ["rd", [["punctuation", "}"]]]]], - ["latte", [["ld", [["punctuation", "{"]]], ["php", [["operator", "/"]]], ["rd", [["punctuation", "}"]]]]], + ["latte", [ + ["ld", [ + ["punctuation", "{"], + ["tag", "aa"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + + ["latte", [ + ["ld", [ + ["punctuation", "{/"], + ["tag", "aa"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + + ["latte", [ + ["ld", [ + ["punctuation", "{"] + ]], + ["php", [ + ["operator", "/"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + "\r\n{", - ["latte", [["ld", [["punctuation", "{"], ["tag", "aa"]]], ["rd", [["punctuation", "}"]]]]], + ["latte", [ + ["ld", [ + ["punctuation", "{"], + ["tag", "aa"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], "}\r\n", - ["latte", [["ld", [["punctuation", "{"]]], ["php", [["number", "10"]]], ["rd", [["punctuation", "}"]]]]], - ["latte", [["ld", [["punctuation", "{"], ["tag", "="]]], ["php", [["number", "10"]]], ["rd", [["punctuation", "}"]]]]], - ["latte", [["ld", [["punctuation", "{"]]], ["php", [["function", "test"], ["punctuation", "("], ["punctuation", ")"]]], ["rd", [["punctuation", "}"]]]]], + + ["latte", [ + ["ld", [ + ["punctuation", "{"] + ]], + ["php", [ + ["number", "10"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + + ["latte", [ + ["ld", [ + ["punctuation", "{"], + ["tag", "="] + ]], + ["php", [ + ["number", "10"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + + ["latte", [ + ["ld", [ + ["punctuation", "{"] + ]], + ["php", [ + ["function", ["test"]], + ["punctuation", "("], + ["punctuation", ")"] + ]], + ["rd", [ + ["punctuation", "}"] + ]] + ]], + "\r\n{'no'}\r\n{\"no\"}\r\n{ no }\r\n", - ["latte", [["ld", [["punctuation", "{"], ["tag", "multi"]]], ["php", ["line"]], ["rd", [["punctuation", "}"]]]]] + + ["latte", [ + ["ld", [ + ["punctuation", "{"], + ["tag", "multi"] + ]], + + ["php", ["line"]], + ["rd", [ + ["punctuation", "}"] + ]] + ]] ] ---------------------------------------------------- diff --git a/tests/languages/php!+css-extras/issue2008.test b/tests/languages/php!+css-extras/issue2008.test index ca5b7cff78..34c084f5ff 100644 --- a/tests/languages/php!+css-extras/issue2008.test +++ b/tests/languages/php!+css-extras/issue2008.test @@ -1,43 +1,43 @@ - - ----------------------------------------------------- - -[ - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "img" - ]], - ["special-attr", [ - ["attr-name", "style"], - ["attr-value", [ - ["punctuation", "="], - ["punctuation", "\""], - ["value", [ - ["property", "width"], - ["punctuation", ":"], - ["php", [ - ["delimiter", ""] - ]], - "%" - ]], - ["punctuation", "\""] - ]] - ]], - ["punctuation", "/>"] - ]] -] - ----------------------------------------------------- - -Checks for #2008 where a part of markup templating's placeholder was tokenized as `number` by CSS Extras. + + +---------------------------------------------------- + +[ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "img" + ]], + ["special-attr", [ + ["attr-name", "style"], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + ["value", [ + ["property", "width"], + ["punctuation", ":"], + ["php", [ + ["delimiter", ""] + ]], + "%" + ]], + ["punctuation", "\""] + ]] + ]], + ["punctuation", "/>"] + ]] +] + +---------------------------------------------------- + +Checks for #2008 where a part of markup templating's placeholder was tokenized as `number` by CSS Extras. diff --git a/tests/languages/php!+php-extras/scope_feature.test b/tests/languages/php!+php-extras/scope_feature.test index bd961681b5..313a5549df 100644 --- a/tests/languages/php!+php-extras/scope_feature.test +++ b/tests/languages/php!+php-extras/scope_feature.test @@ -9,19 +9,27 @@ parent::baz() ["keyword", "static"], ["punctuation", "::"] ]], - ["function", "foo"], ["punctuation", "("], ["punctuation", ")"], + ["function", ["foo"]], + ["punctuation", "("], + ["punctuation", ")"], + ["scope", [ ["keyword", "self"], ["punctuation", "::"] ]], - ["function", "bar"], ["punctuation", "("], ["punctuation", ")"], + ["function", ["bar"]], + ["punctuation", "("], + ["punctuation", ")"], + ["scope", [ ["keyword", "parent"], ["punctuation", "::"] ]], - ["function", "baz"], ["punctuation", "("], ["punctuation", ")"] + ["function", ["baz"]], + ["punctuation", "("], + ["punctuation", ")"] ] ---------------------------------------------------- -Checks for scopes. \ No newline at end of file +Checks for scopes. diff --git a/tests/languages/php/argument-name_feature.test b/tests/languages/php/argument-name_feature.test index 8abbca14de..5d61d2f8c6 100644 --- a/tests/languages/php/argument-name_feature.test +++ b/tests/languages/php/argument-name_feature.test @@ -6,19 +6,22 @@ foo( ---------------------------------------------------- [ - ["function", "foo"], + ["function", ["foo"]], ["punctuation", "("], + ["argument-name", "a"], ["punctuation", ":"], ["string", "'bar'"], ["punctuation", ","], + ["argument-name", "qux"], ["punctuation", ":"], ["string", "'baz'"], + ["punctuation", ")"], ["punctuation", ";"] ] ---------------------------------------------------- -Checks for named arguments. \ No newline at end of file +Checks for named arguments. diff --git a/tests/languages/php/class-name_feature.test b/tests/languages/php/class-name_feature.test index 09f5432e7a..cda1575973 100644 --- a/tests/languages/php/class-name_feature.test +++ b/tests/languages/php/class-name_feature.test @@ -32,7 +32,7 @@ class Foo extends \Package\Bar implements App\Baz {} ["class-name", "Foo"], ["operator", "::"], - ["function", "bar"], + ["function", ["bar"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -42,7 +42,7 @@ class Foo extends \Package\Bar implements App\Baz {} "Foo" ]], ["operator", "::"], - ["function", "bar"], + ["function", ["bar"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -54,7 +54,7 @@ class Foo extends \Package\Bar implements App\Baz {} "Foo" ]], ["operator", "::"], - ["function", "bar"], + ["function", ["bar"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], diff --git a/tests/languages/php/function_feature.test b/tests/languages/php/function_feature.test index d04d07d985..290a76afb6 100644 --- a/tests/languages/php/function_feature.test +++ b/tests/languages/php/function_feature.test @@ -23,6 +23,10 @@ Test::method(); // this is "method" static method $variable->class(); // this "class" should be interpreted as "keyword" Test::class; // This "class" should still be a keyword +mb_string(); // call to a global function +\mb_string(); // namespace \ is global +\a\b\c\mb_string(); // function in \a\b\c namespace + ---------------------------------------------------- [ @@ -49,7 +53,7 @@ Test::class; // This "class" should still be a keyword ["variable", "$a"], ["operator", "->"], - ["function", "if"], + ["function", ["if"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -71,7 +75,7 @@ Test::class; // This "class" should still be a keyword ["variable", "$variable"], ["operator", "->"], - ["function", "foreach"], + ["function", ["foreach"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -79,7 +83,7 @@ Test::class; // This "class" should still be a keyword ["variable", "$variable"], ["operator", "->"], - ["function", "method"], + ["function", ["method"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -87,7 +91,7 @@ Test::class; // This "class" should still be a keyword ["variable", "$var"], ["operator", "->"], - ["function", "match"], + ["function", ["match"]], ["punctuation", "("], ["punctuation", ")"], @@ -104,7 +108,7 @@ Test::class; // This "class" should still be a keyword ["class-name", "Test"], ["operator", "::"], - ["function", "foreach"], + ["function", ["foreach"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -112,7 +116,7 @@ Test::class; // This "class" should still be a keyword ["class-name", "Test"], ["operator", "::"], - ["function", "method"], + ["function", ["method"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", ";"], @@ -132,5 +136,35 @@ Test::class; // This "class" should still be a keyword ["operator", "::"], ["keyword", "class"], ["punctuation", ";"], - ["comment", "// This \"class\" should still be a keyword"] -] \ No newline at end of file + ["comment", "// This \"class\" should still be a keyword"], + + ["function", ["mb_string"]], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// call to a global function"], + + ["function", [ + ["punctuation", "\\"], + "mb_string" + ]], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// namespace \\ is global"], + + ["function", [ + ["punctuation", "\\"], + "a", + ["punctuation", "\\"], + "b", + ["punctuation", "\\"], + "c", + ["punctuation", "\\"], + "mb_string" + ]], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], + ["comment", "// function in \\a\\b\\c namespace"] +] diff --git a/tests/languages/php/string-interpolation_feature.test b/tests/languages/php/string-interpolation_feature.test index 3f86ef5d54..d870eb496d 100644 --- a/tests/languages/php/string-interpolation_feature.test +++ b/tests/languages/php/string-interpolation_feature.test @@ -118,7 +118,7 @@ $value = "$foo[0][1]"; ["punctuation", "{"], ["variable", "$"], ["punctuation", "{"], - ["function", "getName"], + ["function", ["getName"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", "}"], @@ -135,7 +135,7 @@ $value = "$foo[0][1]"; ["punctuation", "{"], ["variable", "$object"], ["operator", "->"], - ["function", "getName"], + ["function", ["getName"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", "}"], @@ -187,7 +187,7 @@ $value = "$foo[0][1]"; ["punctuation", "{"], ["variable", "$string"], ["operator", "->"], - ["function", "interpolation"], + ["function", ["interpolation"]], ["punctuation", "("], ["punctuation", ")"], ["punctuation", "}"],