diff --git a/src/languages/php.js b/src/languages/php.js
index 51fc8e685a..a23b6543c2 100644
--- a/src/languages/php.js
+++ b/src/languages/php.js
@@ -380,6 +380,18 @@ export default function(hljs) {
},
VARIABLE,
FUNCTION_INVOKE,
+ {
+ match: [
+ /const/,
+ regex.concat(WHITESPACE, "+"),
+ IDENT_RE,
+ regex.concat(WHITESPACE, "*="),
+ ],
+ scope: {
+ 1: "keyword",
+ 3: "variable",
+ },
+ },
{
// swallow composed identifiers to avoid parsing them as keywords
match: regex.concat(
diff --git a/test/markup/php/titles.expect.txt b/test/markup/php/titles.expect.txt
new file mode 100644
index 0000000000..03a9daaf19
--- /dev/null
+++ b/test/markup/php/titles.expect.txt
@@ -0,0 +1,22 @@
+final class Example {
+ const FOO='foo';
+
+ public function __construct(
+ public readonly string $name = self::FOO
+ ) {}
+
+ public function getClass(): string {
+ return DateTimeImmutable::class;
+ }
+
+ public function getClassFromSelf(): string {
+ return self::class;
+ }
+
+ public static function getClassFromStatic(): string {
+ return static::class;
+ }
+}
+
+$date = DateTimeImmutable::createFromMutable(new \DateTime());
+echo $date::class;
diff --git a/test/markup/php/titles.txt b/test/markup/php/titles.txt
new file mode 100644
index 0000000000..ffa405fb72
--- /dev/null
+++ b/test/markup/php/titles.txt
@@ -0,0 +1,22 @@
+final class Example {
+ const FOO='foo';
+
+ public function __construct(
+ public readonly string $name = self::FOO
+ ) {}
+
+ public function getClass(): string {
+ return DateTimeImmutable::class;
+ }
+
+ public function getClassFromSelf(): string {
+ return self::class;
+ }
+
+ public static function getClassFromStatic(): string {
+ return static::class;
+ }
+}
+
+$date = DateTimeImmutable::createFromMutable(new \DateTime());
+echo $date::class;