UNPKG

6.22 kBJavaScriptView Raw
1/*! `php` grammar compiled for Highlight.js 11.6.0 */
2(()=>{var e=(()=>{"use strict";return e=>{
3const t=e.regex,a=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,a),n=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,a),o={
4scope:"variable",match:"\\$+"+r},c={scope:"subst",variants:[{begin:/\$\w+/},{
5begin:/\{\$/,end:/\}/}]},i=e.inherit(e.APOS_STRING_MODE,{illegal:null
6}),s="[ \t\n]",l={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{
7illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)
8}),i,e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,
9contains:e.QUOTE_STRING_MODE.contains.concat(c)})]},_={scope:"number",
10variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{
11begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{
12begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{
13begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"
14}],relevance:0
15},d=["false","null","true"],p=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],b=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],E={
16keyword:p,literal:(e=>{const t=[];return e.forEach((e=>{
17t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())
18})),t})(d),built_in:b},u=e=>e.map((e=>e.replace(/\|\d+$/,""))),g={variants:[{
19match:[/new/,t.concat(s,"+"),t.concat("(?!",u(b).join("\\b|"),"\\b)"),n],scope:{
201:"keyword",4:"title.class"}}]},h=t.concat(r,"\\b(?!\\()"),m={variants:[{
21match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{2:"variable.constant"
22}},{match:[/::/,/class/],scope:{2:"variable.language"}},{
23match:[n,t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{1:"title.class",
243:"variable.constant"}},{match:[n,t.concat("::",t.lookahead(/(?!class\b)/))],
25scope:{1:"title.class"}},{match:[n,/::/,/class/],scope:{1:"title.class",
263:"variable.language"}}]},I={scope:"attr",
27match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},f={relevance:0,
28begin:/\(/,end:/\)/,keywords:E,contains:[I,o,m,e.C_BLOCK_COMMENT_MODE,l,_,g]
29},O={relevance:0,
30match:[/\b/,t.concat("(?!fn\\b|function\\b|",u(p).join("\\b|"),"|",u(b).join("\\b|"),"\\b)"),r,t.concat(s,"*"),t.lookahead(/(?=\()/)],
31scope:{3:"title.function.invoke"},contains:[f]};f.contains.push(O)
32;const v=[I,m,e.C_BLOCK_COMMENT_MODE,l,_,g];return{case_insensitive:!1,
33keywords:E,contains:[{begin:t.concat(/#\[\s*/,n),beginScope:"meta",end:/]/,
34endScope:"meta",keywords:{literal:d,keyword:["new","array"]},contains:[{
35begin:/\[/,end:/]/,keywords:{literal:d,keyword:["new","array"]},
36contains:["self",...v]},...v,{scope:"meta",match:n}]
37},e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{
38scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,
39keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,
40contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{
41begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{
42begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},o,O,m,{
43match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},g,{
44scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,
45excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"
46},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",
47begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:E,
48contains:["self",o,m,e.C_BLOCK_COMMENT_MODE,l,_]}]},{scope:"class",variants:[{
49beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
50illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
51beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
52beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
53contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{
54beginKeywords:"use",relevance:0,end:";",contains:[{
55match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},l,_]}
56}})();hljs.registerLanguage("php",e)})();
\No newline at end of file