Skip to content

Commit

Permalink
php: fix highlight of fully-qualified identifiers (fix #1718) (#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsfisis committed Apr 25, 2023
1 parent a7958ba commit 1e2c367
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rouge/lexers/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def builtins

id = /[\p{L}_][\p{L}\p{N}_]*/
ns = /(?:#{id}\\)+/
id_with_ns = /(?:#{ns})?#{id}/
id_with_ns = /\\?(?:#{ns})?#{id}/

start do
case @start_inline
Expand Down Expand Up @@ -273,7 +273,7 @@ def builtins
state :in_catch do
rule %r/\(/, Punctuation
rule %r/\|/, Operator
rule id, Name::Class
rule id_with_ns, Name::Class
mixin :escape
mixin :whitespace
mixin :return
Expand Down
5 changes: 5 additions & 0 deletions spec/visual/samples/php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ class Test {
throw new MyException();
} catch (MyException | MyOtherException $e) {
var_dump(get_class($e));
} catch (\Exception $x) {
throw $x;
}
}
}
Expand Down Expand Up @@ -362,4 +364,7 @@ class SetUp {
public function fileExists() {}
}

function f(\Ns1\Ns2\Ns3\Class $x) {
}

?>

0 comments on commit 1e2c367

Please sign in to comment.