php.min.js 6.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*! `php` grammar compiled for Highlight.js 11.7.0 */
  2. (()=>{var e=(()=>{"use strict";return e=>{
  3. const 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={
  4. scope:"variable",match:"\\$+"+r},c={scope:"subst",variants:[{begin:/\$\w+/},{
  5. begin:/\{\$/,end:/\}/}]},i=e.inherit(e.APOS_STRING_MODE,{illegal:null
  6. }),s="[ \t\n]",l={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{
  7. illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)
  8. }),i,e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,
  9. contains:e.QUOTE_STRING_MODE.contains.concat(c)})]},_={scope:"number",
  10. variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{
  11. begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{
  12. begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{
  13. begin:"(?:\\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={
  16. keyword:p,literal:(e=>{const t=[];return e.forEach((e=>{
  17. t.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:[{
  19. match:[/new/,t.concat(s,"+"),t.concat("(?!",u(b).join("\\b|"),"\\b)"),n],scope:{
  20. 1:"keyword",4:"title.class"}}]},h=t.concat(r,"\\b(?!\\()"),m={variants:[{
  21. match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{2:"variable.constant"
  22. }},{match:[/::/,/class/],scope:{2:"variable.language"}},{
  23. match:[n,t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{1:"title.class",
  24. 3:"variable.constant"}},{match:[n,t.concat("::",t.lookahead(/(?!class\b)/))],
  25. scope:{1:"title.class"}},{match:[n,/::/,/class/],scope:{1:"title.class",
  26. 3:"variable.language"}}]},I={scope:"attr",
  27. match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},f={relevance:0,
  28. begin:/\(/,end:/\)/,keywords:E,contains:[I,o,m,e.C_BLOCK_COMMENT_MODE,l,_,g]
  29. },O={relevance:0,
  30. match:[/\b/,t.concat("(?!fn\\b|function\\b|",u(p).join("\\b|"),"|",u(b).join("\\b|"),"\\b)"),r,t.concat(s,"*"),t.lookahead(/(?=\()/)],
  31. scope:{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,
  33. keywords:E,contains:[{begin:t.concat(/#\[\s*/,n),beginScope:"meta",end:/]/,
  34. endScope:"meta",keywords:{literal:d,keyword:["new","array"]},contains:[{
  35. begin:/\[/,end:/]/,keywords:{literal:d,keyword:["new","array"]},
  36. contains:["self",...v]},...v,{scope:"meta",match:n}]
  37. },e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{
  38. scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,
  39. keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,
  40. contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{
  41. begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{
  42. begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},o,O,m,{
  43. match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},g,{
  44. scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,
  45. excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"
  46. },e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",
  47. begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:E,
  48. contains:["self",o,m,e.C_BLOCK_COMMENT_MODE,l,_]}]},{scope:"class",variants:[{
  49. beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
  50. illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
  51. beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
  52. beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
  53. contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{
  54. beginKeywords:"use",relevance:0,end:";",contains:[{
  55. match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},l,_]}
  56. }})();hljs.registerLanguage("php",e)})();