class Rouge::Lexers::PHP
Public Class Methods
builtins()
click to toggle source
# File lib/rouge/lexers/php.rb, line 30 def self.builtins Kernel::load File.join(Lexers::BASE_DIR, 'php/keywords.rb') builtins end
detect?(text)
click to toggle source
# File lib/rouge/lexers/php.rb, line 85 def self.detect?(text) return true if text.shebang?('php') return false if /^<\?hh/ =~ text return true if /^<\?php/ =~ text end
keywords()
click to toggle source
# File lib/rouge/lexers/php.rb, line 64 def self.keywords # (echo parent ; echo self ; sed -nE 's/<ST_IN_SCRIPTING>"((__)?[[:alpha:]_]+(__)?)".*/\1/p' zend_language_scanner.l | tr '[A-Z]' '[a-z]') | sort -u | grep -Fwv -e isset -e unset -e empty -e const -e use -e function -e namespace # - isset, unset and empty are actually keywords (directly handled by PHP's lexer but let's pretend these are functions, you use them like so) # - self and parent are kind of keywords, they are not handled by PHP's lexer # - use, const, namespace and function are handled by specific rules to highlight what's next to the keyword # - class is also listed here, in addition to the rule below, to handle anonymous classes @keywords ||= Set.new %w( old_function cfunction __class__ __dir__ __file__ __function__ __halt_compiler __line__ __method__ __namespace__ __trait__ abstract and array as break callable case catch class clone continue declare default die do echo else elseif enddeclare endfor endforeach endif endswitch endwhile eval exit extends final finally fn for foreach global goto if implements include include_once instanceof insteadof interface list new or parent print private protected public require require_once return self static switch throw trait try var while xor yield ) end
new(*)
click to toggle source
Calls superclass method
# File lib/rouge/lexers/php.rb, line 20 def initialize(*) super # if truthy, the lexer starts highlighting with php code # (no <?php required) @start_inline = bool_option(:start_inline) { :guess } @funcnamehighlighting = bool_option(:funcnamehighlighting) { true } @disabledmodules = list_option(:disabledmodules) end
Public Instance Methods
builtins()
click to toggle source
# File lib/rouge/lexers/php.rb, line 35 def builtins return [] unless @funcnamehighlighting @builtins ||= Set.new.tap do |builtins| self.class.builtins.each do |mod, fns| next if @disabledmodules.include? mod builtins.merge(fns) end end end