Skip to content

Commit 439e3bd

Browse files
voladoRunDevelopment
authored andcommitted
Made false, true, and null constants in PHP (#1694)
- This adds the `constant` alias to `false` and `true`. - `null` is no longer `keyword` but a `constant`.
1 parent 7def8f5 commit 439e3bd

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

components/prism-php.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212
*/
1313
(function (Prism) {
1414
Prism.languages.php = Prism.languages.extend('clike', {
15-
'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,
16-
'constant': /\b[A-Z_][A-Z0-9_]*\b/,
15+
'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|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
16+
'boolean': {
17+
pattern: /\b(?:false|true)\b/i,
18+
alias: 'constant'
19+
},
20+
'constant': [
21+
/\b[A-Z_][A-Z0-9_]*\b/,
22+
/\b(?:null)\b/i,
23+
],
1724
'comment': {
1825
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1926
lookbehind: true

components/prism-php.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FALSE
2+
false
3+
TRUE
4+
true
5+
6+
----------------------------------------------------
7+
8+
[
9+
["boolean", "FALSE"],
10+
["boolean", "false"],
11+
["boolean", "TRUE"],
12+
["boolean", "true"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for booleans.

tests/languages/php/constant_feature.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
null
12
_
23
X
34
AZ
@@ -7,6 +8,7 @@ FOOBAR_42
78
----------------------------------------------------
89

910
[
11+
["constant", "null"],
1012
["constant", "_"],
1113
["constant", "X"],
1214
["constant", "AZ"],

tests/languages/php/keyword_feature.test

-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ isset
4646
list
4747
namespace;
4848
new;
49-
null
5049
or
5150
parent
5251
print
@@ -119,7 +118,6 @@ yield
119118
["keyword", "list"],
120119
["keyword", "namespace"], ["punctuation", ";"],
121120
["keyword", "new"], ["punctuation", ";"],
122-
["keyword", "null"],
123121
["keyword", "or"],
124122
["keyword", "parent"],
125123
["keyword", "print"],

0 commit comments

Comments
 (0)