diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index b95bde50d95..e7d5e95fb15 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -571,20 +571,13 @@ public function collectFromCode($content, $fileName, Module $module) if (is_array($token)) { list($id, $text) = $token; - // PHP 8 namespace tokens - if (\defined('T_NAME_QUALIFIED') && in_array($id, [T_NAME_FULLY_QUALIFIED, T_NAME_QUALIFIED])) { - $inNamespace = true; - $currentClass[] = $text; - continue; - } - // Check class if ($id === T_NAMESPACE) { $inNamespace = true; $currentClass = []; continue; } - if ($inNamespace && $id === T_STRING) { + if ($inNamespace && ($id === T_STRING || (defined('T_NAME_QUALIFIED') && $id === T_NAME_QUALIFIED))) { $currentClass[] = $text; continue; } diff --git a/tests/php/i18n/i18nTextCollectorTest.php b/tests/php/i18n/i18nTextCollectorTest.php index e9d22805a05..6812c9cc6fe 100644 --- a/tests/php/i18n/i18nTextCollectorTest.php +++ b/tests/php/i18n/i18nTextCollectorTest.php @@ -300,9 +300,14 @@ public function testCollectFromCodeNamespace() assertEquals( [ 'SilverStripe\\Framework\\Core\\MyClass.NEWLINES' => "New Lines",