Skip to content

Commit

Permalink
update typehinting for PHP 7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
julp committed Dec 21, 2016
1 parent e6b0d94 commit f6747e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/rouge/lexers/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,13 @@ def self.analyze_text(text)
groups Keyword, Text, Keyword
end

rule /(true|false|null)\b/i, Keyword::Constant
rule /(int|float|bool|string|resource|object|mixed|numeric|void)\b/i, Keyword::Type
rule /(?:true|false|null)\b/i, Keyword::Constant
# PHP 7.0: generalized typehinting
# PHP 7.1: null allowed by prefixing type by a '?' + void (which is not nullable) and iterable added
# from builtin_types in Zend/zend_compile.c
rule /(?:void|\??(?:int|float|bool|string|iterable))\b/i, Keyword::Type
# PHP 7.1: self and callable are keywords, handle them here as nullable types
rule /\??(?:self|callable)\b/i, Keyword::Type

rule /(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?/i, Num::Float
rule /\d+e[+-]?\d+/i, Num::Float
Expand Down

0 comments on commit f6747e0

Please sign in to comment.