Skip to content

Commit

Permalink
Update PHP keywords (#1690)
Browse files Browse the repository at this point in the history
This removes PHP 4 specific keywords and adds new PHP keywords.

Keywords previously classified as functions are now classified as keywords.
  • Loading branch information
volado authored and RunDevelopment committed Jan 3, 2019
1 parent f1026b4 commit 55fb0f8
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 57 deletions.
2 changes: 1 addition & 1 deletion components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]*?\*\/|\/\/.*)/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 126 additions & 55 deletions tests/languages/php/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -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"]
]

----------------------------------------------------
Expand Down

0 comments on commit 55fb0f8

Please sign in to comment.