From 521c8179b1722a393ebeaceb9796591575a5325b Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 10 Nov 2022 15:35:41 +1300 Subject: [PATCH] ENH Correctly parse SomeClass::class syntax in textcollection --- src/i18n/TextCollection/i18nTextCollector.php | 76 +++++++++++++++++-- tests/php/i18n/i18nTextCollectorTest.php | 58 ++++++++++++++ 2 files changed, 129 insertions(+), 5 deletions(-) diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index e7d5e95fb15..9578d0d6171 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -548,9 +548,10 @@ protected function getFileListForModule(Module $module) */ public function collectFromCode($content, $fileName, Module $module) { - // Get namespace either from $fileName or $module fallback + // Get "namespace" either from $fileName or $module fallback $namespace = $fileName ? basename($fileName) : $module->getName(); + $usedFQCNs = []; $entities = []; $tokens = token_get_all("getManifest()->getModule('i18ntestmodule'); + $php = <<assertEquals( + [ + 'SilverStripe\\Versioned\\Versioned.OTHER_NAMESPACE' => "New Lines", + 'SilverStripe\\Framework\\Core\\SameNamespaceClass.SAME_NAMESPACE' => 'Slash=\\, Quote=\'', + 'Some\\Space\\MyClass.ALIAS_CLASS' => 'Slash=\\, Quote="', + 'NoNamespaceClass.NO_NAMESPACE' => 'Self Class', + ], + $c->collectFromCode($php, null, $mymodule) + ); + } public function testNewlinesInEntityValues() {