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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
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"]
]
----------------------------------------------------