Commit 55fb0f8e2efbd71b61158664387c246fe9fc1c2e

volado 2019-01-03T17:22:02

Update PHP keywords (#1690) This removes PHP 4 specific keywords and adds new PHP keywords. Keywords previously classified as functions are now classified as keywords.

diff --git a/components/prism-php.js b/components/prism-php.js
index dc89d56..5011ff3 100644
--- a/components/prism-php.js
+++ b/components/prism-php.js
@@ -12,7 +12,7 @@
  */
 (function (Prism) {
 	Prism.languages.php = Prism.languages.extend('clike', {
-		'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
+		'keyword': /\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|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|null|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
 		'constant': /\b[A-Z_][A-Z0-9_]*\b/,
 		'comment': {
 			pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
diff --git a/components/prism-php.min.js b/components/prism-php.min.js
index 373c168..bfc3293 100644
--- a/components/prism-php.min.js
+++ b/components/prism-php.min.js
@@ -1 +1 @@
-!function(e){e.languages.php=e.languages.extend("clike",{keyword:/\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,constant:/\b[A-Z_][A-Z0-9_]*\b/,comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0}}),e.languages.insertBefore("php","string",{"shell-comment":{pattern:/(^|[^\\])#.*/,lookbehind:!0,alias:"comment"}}),e.languages.insertBefore("php","keyword",{delimiter:{pattern:/\?>|<\?(?:php|=)?/i,alias:"important"},variable:/\$+(?:\w+\b|(?={))/i,"package":{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/,lookbehind:!0,inside:{punctuation:/\\/}}}),e.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/,lookbehind:!0}});var n={pattern:/{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,lookbehind:!0,inside:{rest:e.languages.php}};e.languages.insertBefore("php","string",{"nowdoc-string":{pattern:/<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},"heredoc-string":{pattern:/<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:n}},"single-quoted-string":{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0,alias:"string"},"double-quoted-string":{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,alias:"string",inside:{interpolation:n}}}),delete e.languages.php.string,e.hooks.add("before-tokenize",function(n){if(/(?:<\?php|<\?)/gi.test(n.code)){var t=/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/gi;e.languages["markup-templating"].buildPlaceholders(n,"php",t)}}),e.hooks.add("after-tokenize",function(n){e.languages["markup-templating"].tokenizePlaceholders(n,"php")})}(Prism);
\ No newline at end of file
+!function(e){e.languages.php=e.languages.extend("clike",{keyword:/\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|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|null|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,constant:/\b[A-Z_][A-Z0-9_]*\b/,comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0}}),e.languages.insertBefore("php","string",{"shell-comment":{pattern:/(^|[^\\])#.*/,lookbehind:!0,alias:"comment"}}),e.languages.insertBefore("php","keyword",{delimiter:{pattern:/\?>|<\?(?:php|=)?/i,alias:"important"},variable:/\$+(?:\w+\b|(?={))/i,"package":{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/,lookbehind:!0,inside:{punctuation:/\\/}}}),e.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/,lookbehind:!0}});var n={pattern:/{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,lookbehind:!0,inside:{rest:e.languages.php}};e.languages.insertBefore("php","string",{"nowdoc-string":{pattern:/<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},"heredoc-string":{pattern:/<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:n}},"single-quoted-string":{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0,alias:"string"},"double-quoted-string":{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,alias:"string",inside:{interpolation:n}}}),delete e.languages.php.string,e.hooks.add("before-tokenize",function(n){if(/(?:<\?php|<\?)/gi.test(n.code)){var t=/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/gi;e.languages["markup-templating"].buildPlaceholders(n,"php",t)}}),e.hooks.add("after-tokenize",function(n){e.languages["markup-templating"].tokenizePlaceholders(n,"php")})}(Prism);
\ No newline at end of file
diff --git a/tests/languages/php/keyword_feature.test b/tests/languages/php/keyword_feature.test
index 9505114..1a8f47d 100644
--- a/tests/languages/php/keyword_feature.test
+++ b/tests/languages/php/keyword_feature.test
@@ -1,74 +1,145 @@
-and or xor array
-as break case
-cfunction
+__halt_compiler
+abstract
+and
+array
+as
+break
+callable
+case
+catch
 class;
-const continue
-declare default
-die do else
-elseif enddeclare
-endfor endforeach
-endif endswitch
+clone
+const
+continue
+declare
+default
+die
+do
+echo
+else
+elseif
+empty
+enddeclare
+endfor
+endforeach
+endif
+endswitch
 endwhile
+eval
+exit
 extends;
-for foreach function
-include include_once
-global if
+final
+finally
+for
+foreach
+function
+global
+goto
+if
+implements;
+include
+include_once
+instanceof;
+insteadof
+interface;
+isset
+list
+namespace;
 new;
+null
+or
+parent
+print
+private
+protected
+public
+require
+require_once
 return
-static switch
+static
+switch
+throw
+trait;
+try
+unset
 use;
-require require_once
-var while abstract
-interface;
-public
-implements;
-private
-protected parent
-throw null echo
-print trait;
-namespace;
-final yield goto
-instanceof;
-finally
-try catch
+var
+while
+xor
+yield
 
 ----------------------------------------------------
 
 [
-	["keyword", "and"], ["keyword", "or"], ["keyword", "xor"], ["keyword", "array"],
-	["keyword", "as"], ["keyword", "break"], ["keyword", "case"],
-	["keyword", "cfunction"],
+	["keyword", "__halt_compiler"],
+	["keyword", "abstract"],
+	["keyword", "and"],
+	["keyword", "array"],
+	["keyword", "as"],
+	["keyword", "break"],
+	["keyword", "callable"],
+	["keyword", "case"],
+	["keyword", "catch"],
 	["keyword", "class"], ["punctuation", ";"],
-	["keyword", "const"], ["keyword", "continue"],
-	["keyword", "declare"], ["keyword", "default"],
-	["keyword", "die"], ["keyword", "do"], ["keyword", "else"],
-	["keyword", "elseif"], ["keyword", "enddeclare"],
-	["keyword", "endfor"], ["keyword", "endforeach"],
-	["keyword", "endif"], ["keyword", "endswitch"],
+	["keyword", "clone"],
+	["keyword", "const"],
+	["keyword", "continue"],
+	["keyword", "declare"],
+	["keyword", "default"],
+	["keyword", "die"],
+	["keyword", "do"],
+	["keyword", "echo"],
+	["keyword", "else"],
+	["keyword", "elseif"],
+	["keyword", "empty"],
+	["keyword", "enddeclare"],
+	["keyword", "endfor"],
+	["keyword", "endforeach"],
+	["keyword", "endif"],
+	["keyword", "endswitch"],
 	["keyword", "endwhile"],
+	["keyword", "eval"],
+	["keyword", "exit"],
 	["keyword", "extends"], ["punctuation", ";"],
-	["keyword", "for"], ["keyword", "foreach"], ["keyword", "function"],
-	["keyword", "include"], ["keyword", "include_once"],
-	["keyword", "global"], ["keyword", "if"],
+	["keyword", "final"],
+	["keyword", "finally"],
+	["keyword", "for"],
+	["keyword", "foreach"],
+	["keyword", "function"],
+	["keyword", "global"],
+	["keyword", "goto"],
+	["keyword", "if"],
+	["keyword", "implements"], ["punctuation", ";"],
+	["keyword", "include"],
+	["keyword", "include_once"],
+	["keyword", "instanceof"], ["punctuation", ";"],
+	["keyword", "insteadof"],
+	["keyword", "interface"], ["punctuation", ";"],
+	["keyword", "isset"],
+	["keyword", "list"],
+	["keyword", "namespace"], ["punctuation", ";"],
 	["keyword", "new"], ["punctuation", ";"],
+	["keyword", "null"],
+	["keyword", "or"],
+	["keyword", "parent"],
+	["keyword", "print"],
+	["keyword", "private"],
+	["keyword", "protected"],
+	["keyword", "public"],
+	["keyword", "require"],
+	["keyword", "require_once"],
 	["keyword", "return"],
-	["keyword", "static"], ["keyword", "switch"],
+	["keyword", "static"],
+	["keyword", "switch"],
+	["keyword", "throw"],
+	["keyword", "trait"],  ["punctuation", ";"],
+	["keyword", "try"],
+	["keyword", "unset"],
 	["keyword", "use"], ["punctuation", ";"],
-	["keyword", "require"], ["keyword", "require_once"],
-	["keyword", "var"], ["keyword", "while"], ["keyword", "abstract"],
-	["keyword", "interface"], ["punctuation", ";"],
-	["keyword", "public"],
-	["keyword", "implements"], ["punctuation", ";"],
-	["keyword", "private"],
-	["keyword", "protected"], ["keyword", "parent"],
-	["keyword", "throw"], ["keyword", "null"], ["keyword", "echo"],
-	["keyword", "print"],
-	["keyword", "trait"], ["punctuation", ";"],
-	["keyword", "namespace"], ["punctuation", ";"],
-	["keyword", "final"], ["keyword", "yield"], ["keyword", "goto"],
-	["keyword", "instanceof"], ["punctuation", ";"],
-	["keyword", "finally"],
-	["keyword", "try"], ["keyword", "catch"]
+	["keyword", "var"],
+	["keyword", "while"],
+	["keyword", "xor"],
+	["keyword", "yield"]
 ]
 
 ----------------------------------------------------