## Syntax highlighting for PHP. # Download latest version here: # https://misc.daniel-marschall.de/code/better_nanorc/php.nanorc # --- # Source: https://github.com/scopatz/nanorc/blob/master/php.nanorc # Modified by Daniel Marschall: # 18 December 2022 # - Minor changes to match current version of the nanorc of Debian 11 # 06 April 2018 # - Added PHPdoc # - Corrected highlighting of strings and changed highlighting order # - Fixed inline variables from {$...} to ${...} # - Highlighted reminders (TODO, FIXME etc) # 03 April 2018 # - Added header, magic and comment # - Added new keywords # - Removed "in" (this is not a keyword) # - Keywords are now also highlighted if they are at the beginning or end of a line # - Added "Spaces in front of tabs" mark # - Changed code for "trailing whitespace" (now also supports lines with only whitespaces) # TODO: # - Things like @see, '#' or '//' cannot be used inside a string syntax php "\.(php[234578s~]?|phtml|ctp)$" header "^#!.*php[-0-9._]*" magic "PHP script" comment "//" color white start="<\?(php|=)?" end="\?>" # Functions # TODO: Debian 11 has "\<[A-Za-z_][A-Za-z_0-9]*\(" => is this better? color brightblue "([a-zA-Z0-9_-]*)\(" # This is the current list of keywords (https://php.net/manual/de/reserved.keywords.php , 03 April 2018) # with following changes: # REMOVED: @, FALSE, NULL, TRUE # ADDED: define, false, null, true # 18.12.2022 Added fn, match, readonly color green "(^|[^a-z0-9_-]{1})(__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|define|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|false|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|new|or|null|print|private|protected|public|readonly|require|require_once|return|static|switch|throw|trait|true|try|unset|use|var|while|xor|yield)([^a-z0-9_-]{1}|$)" # Constructs color brightblue "(class|extends) ([a-zA-Z0-9_]*)" # Control flow. color magenta "\<(break|continue|goto|return)\>" # Operators. color brightcyan "\<(and|or|xor)\>" # Cases color brightblue "[a-zA-Z0-9]+:" # Numbers color magenta "[+-]*([0-9]\.)*[0-9]+([eE][+-]?([0-9]\.)*[0-9])*" color magenta "0x[0-9a-zA-Z]*" # Special Characters color yellow "[.,{}();]" color yellow "\[" color yellow "\]" color yellow "[=][^>]" # Double quote strings #color red ""([^"]|\\")*"" color red ""(\.|[^"])*"" # Variables # TODO: Debian 11 has "\$[A-Za-z_][A-Za-z_0-9]*" => is this better? color white "\$[a-zA-Z_0-9$]*|[=!<>]" color white "\->[a-zA-Z_0-9$]*|[=!<>]" # Special Variables color brightblue "(\$this|parent::|self::|\$this->)" # Single quote strings #color red "'([^']|\\')*'" color red "'(\.|[^'])*'" # Bitwise Operations color magenta "(\;|\||\^){1}" # And/Or/SRO/etc color green "(\;\;|\|\||::|=>|->)" # Inline Variables color white "\$\{[^}]*\}" # PHP Tags color red "(<\?(php)?|\?>)" # General HTML color red start="\?>" end="<\?(php|=)?" # One-Line Comments color brightyellow "(#.*|//.*)$" # multi-line comments color brightyellow start="/\*" end="\*/" # PHP doc color brightblue start="/\*\*" end="\*/" # @see, @param etc color green "@[0-9a-zA-Z]*" # trailing whitespace color ,green "[[:space:]]+$" # Spaces in front of tabs. (Attention: There is a tab in this expression) color ,red " + +" # Reminders color ,red "\<(FIXME|TODO|XXX|BUGBUG)\>" # Original code as of Debian 11 # # # ## Syntax highlighting for PHP. # # syntax php "\.(php[23457s~]?|phtml|ctp)$" # magic "PHP script" # comment "//" # # # PHP markings. # color brightgreen "(<\?(php)?|\?>)" # # # Function names. # color white "\<[A-Za-z_][A-Za-z_0-9]*\(" # # Variable names. # color cyan "\$[A-Za-z_][A-Za-z_0-9]*" # # # Types. # color green "\<(array|bool|callable|const|float|global|int|object|string|var)\>" # # # Directives and structure. # color brightcyan "\<(abstract|as|class|clone|(end)?declare|extends|function|implements|include(_once)?|inst(ance|ead)of|interface|namespace|new|private|protected|public|require(_once)?|static|trait|use|yield)\>" # color brightcyan "\<(case|catch|default|do|echo|else(if)?|end(for(each)?|if|switch|while)|final(ly)?|for(each)?|if|print|switch|throw|try|while)\>" # # Operators. # color brightcyan "\<(and|or|xor)\>" # # # Control flow. # color magenta "\<(break|continue|goto|return)\>" # # # Strings. # color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'" # # # Comments. # color brightblue "(^|[[:space:]]+)//.*" # color brightblue start="/\*" end="\*/" # # # Trailing whitespace. # color ,green "[[:space:]]+$"