Skip to content

Commit bc87d0a

Browse files
committed
php: Support typed class constants
1 parent b5876da commit bc87d0a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/rouge/lexers/php.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ def builtins
280280
end
281281

282282
state :in_const do
283+
rule %r/(\??#{id})(\s+)(#{id})/i do
284+
groups Keyword::Type, Text, Name::Constant
285+
end
283286
rule id, Name::Constant
284287
rule %r/=/, Operator, :in_assign
285288
mixin :escape

spec/visual/samples/php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ class C {
190190
public static ?string $a = "";
191191
public static int $b = 0;
192192

193+
const bool CONST_1 = true;
194+
public const int CONST_2 = 1;
195+
protected const float CONST_3 = 1.0;
196+
private const string CONST_4 = "foo";
197+
const ?array CONST_5 = [];
198+
193199
public function __construct(
194200
public $foo,
195201
protected readonly $bar,

0 commit comments

Comments
 (0)