diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index 3d3d6fa6f8f..7bc44598b56 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -602,6 +602,7 @@ public function collectFromCode($content, $fileName, Module $module) $entities = []; $tokens = token_get_all("getManifest()->getModule('i18ntestmodule'); + $php = <<someMethod(_t( + MyClass::class . '.SOMETHING_A', + 'something a', + )); + }); + } + + public function getNewLinesWithSomething(\$class, \$something) { + Deprecation::withSuppressedNotice(function () use (\$something) { + \$this->someMethod(_t( + MyClass::class . '.SOMETHING_B', + 'something {something}', + ['something' => \$something] + )); + }); + } + + public function getNewLinesWithSomething(\$class, \$something) { + Deprecation::withSuppressedNotice(function ( + \$myparam + ) use (\$something) { + \$this->someMethod(_t( + MyClass::class . '.SOMETHING_C', + 'something {something} {myparam}', + ['something' => \$something, 'myparam' => \$myparam] + )); + }); + } +} +PHP; + $this->assertEquals( + [ + 'SilverStripe\\Framework\\Core\\MyClass.SOMETHING_A' => "something a", + 'SilverStripe\\Framework\\Core\\MyClass.SOMETHING_B' => "something {something}", + 'SilverStripe\\Framework\\Core\\MyClass.SOMETHING_C' => "something {something} {myparam}", + ], + $c->collectFromCode($php, null, $mymodule) + ); + } + public function testCollectFromEntityProvidersInWebRoot() { // Collect from i18nProviderClass