-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp.js
101 lines (101 loc) · 2.89 KB
/
php.js
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
module.exports = function(hljs) {
var VARIABLE = {
className: 'variable', begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
};
var STRINGS = [
hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
{
className: 'string',
begin: 'b"', end: '"',
contains: [hljs.BACKSLASH_ESCAPE]
},
{
className: 'string',
begin: 'b\'', end: '\'',
contains: [hljs.BACKSLASH_ESCAPE]
}
];
var NUMBERS = [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE];
var TITLE = {
className: 'title', begin: hljs.UNDERSCORE_IDENT_RE
};
return {
case_insensitive: true,
keywords:
'and include_once list abstract global private echo interface as static endswitch ' +
'array null if endwhile or const for endforeach self var while isset public ' +
'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' +
'return implements parent clone use __CLASS__ __LINE__ else break print eval new ' +
'catch __METHOD__ case exception php_user_filter default die require __FUNCTION__ ' +
'enddeclare final try this switch continue endfor endif declare unset true false ' +
'namespace trait goto instanceof insteadof __DIR__ __NAMESPACE__ __halt_compiler',
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.HASH_COMMENT_MODE,
{
className: 'comment',
begin: '/\\*', end: '\\*/',
contains: [{
className: 'phpdoc',
begin: '\\s@[A-Za-z]+'
}]
},
{
className: 'comment',
excludeBegin: true,
begin: '__halt_compiler.+?;', endsWithParent: true
},
{
className: 'string',
begin: '<<<[\'"]?\\w+[\'"]?$', end: '^\\w+;',
contains: [hljs.BACKSLASH_ESCAPE]
},
{
className: 'preprocessor',
begin: '<\\?php',
relevance: 10
},
{
className: 'preprocessor',
begin: '\\?>'
},
VARIABLE,
{
className: 'function',
beginWithKeyword: true, end: '{',
keywords: 'function',
illegal: '\\$|\\[|%',
contains: [
TITLE,
{
className: 'params',
begin: '\\(', end: '\\)',
contains: [
'self',
VARIABLE,
hljs.C_BLOCK_COMMENT_MODE
].concat(STRINGS).concat(NUMBERS)
}
]
},
{
className: 'class',
beginWithKeyword: true, end: '{',
keywords: 'class',
illegal: '[:\\(\\$]',
contains: [
{
beginWithKeyword: true, endsWithParent: true,
keywords: 'extends',
contains: [TITLE]
},
TITLE
]
},
{
begin: '=>' // No markup, just a relevance booster
}
].concat(STRINGS).concat(NUMBERS)
};
};