Blame view

docs/assets/js/language/php.js 3.26 KB
5a739853   patrick.he   commit
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
  /**
   * PHP patterns
   *
   * @author Craig Campbell
   * @version 1.0.8
   */
  Rainbow.extend('php', [
      {
          'name': 'support',
          'pattern': /\becho\b/g
      },
      {
          'matches': {
              1: 'variable.dollar-sign',
              2: 'variable'
          },
          'pattern': /(\$)(\w+)\b/g
      },
      {
          'name': 'constant.language',
          'pattern': /true|false|null/ig
      },
      {
          'name': 'constant',
          'pattern': /\b[A-Z0-9_]{2,}\b/g
      },
      {
          'name': 'keyword.dot',
          'pattern': /\./g
      },
      {
          'name': 'keyword',
          'pattern': /\b(die|end(for(each)?|switch|if)|case|require(_once)?|include(_once)?)(?=\(|\b)/g
      },
      {
          'matches': {
              1: 'keyword',
              2: {
                  'name': 'support.class',
                  'pattern': /\w+/g
              }
          },
          'pattern': /(instanceof)\s([^\$].*?)(\)|;)/g
      },
  
      /**
       * these are the top 50 most used PHP functions
       * found from running a script and checking the frequency of each function
       * over a bunch of popular PHP frameworks then combining the results
       */
      {
          'matches': {
              1: 'support.function'
          },
          'pattern': /\b(array(_key_exists|_merge|_keys|_shift)?|isset|count|empty|unset|printf|is_(array|string|numeric|object)|sprintf|each|date|time|substr|pos|str(len|pos|tolower|_replace|totime)?|ord|trim|in_array|implode|end|preg_match|explode|fmod|define|link|list|get_class|serialize|file|sort|mail|dir|idate|log|intval|header|chr|function_exists|dirname|preg_replace|file_exists)(?=\()/g
      },
      {
          'name': 'variable.language.php-tag',
          'pattern': /(<\?(php)?|\?>)/g
      },
      {
          'matches': {
              1: 'keyword.namespace',
              2: {
                  'name': 'support.namespace',
                  'pattern': /\w+/g
              }
          },
          'pattern': /\b(namespace|use)\s(.*?);/g
      },
      {
          'matches': {
              1: 'storage.modifier',
              2: 'storage.class',
              3: 'entity.name.class',
              4: 'storage.modifier.extends',
              5: 'entity.other.inherited-class',
              6: 'storage.modifier.extends',
              7: 'entity.other.inherited-class'
          },
          'pattern': /\b(abstract|final)?\s?(class|interface|trait)\s(\w+)(\sextends\s)?([\w\\]*)?(\simplements\s)?([\w\\]*)?\s?\{?(\n|\})/g
      },
      {
          'name': 'keyword.static',
          'pattern': /self::|static::/g
      },
      {
          'matches': {
              1: 'storage.function',
              2: 'support.magic'
          },
          'pattern': /(function)\s(__.*?)(?=\()/g
      },
      {
          'matches': {
              1: 'keyword.new',
              2: {
                  'name': 'support.class',
                  'pattern': /\w+/g
              }
          },
          'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;)/g
      },
      {
          'matches': {
              1: {
                  'name': 'support.class',
                  'pattern': /\w+/g
              },
              2: 'keyword.static'
          },
          'pattern': /([\w\\]*?)(::)(?=\b|\$)/g
      },
      {
          'matches': {
              2: {
                  'name': 'support.class',
                  'pattern': /\w+/g
              }
          },
          'pattern': /(\(|,\s?)([\w\\]*?)(?=\s\$)/g
      }
  ]);