mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10522 from creative-commoners/pulls/4.11/backport-textcollector-fix
Fix i18nTextCollector produces corrupt output / namespaces when runni…
This commit is contained in:
commit
0b80643210
@ -571,20 +571,13 @@ class i18nTextCollector
|
|||||||
if (is_array($token)) {
|
if (is_array($token)) {
|
||||||
list($id, $text) = $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
|
// Check class
|
||||||
if ($id === T_NAMESPACE) {
|
if ($id === T_NAMESPACE) {
|
||||||
$inNamespace = true;
|
$inNamespace = true;
|
||||||
$currentClass = [];
|
$currentClass = [];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($inNamespace && $id === T_STRING) {
|
if ($inNamespace && ($id === T_STRING || (defined('T_NAME_QUALIFIED') && $id === T_NAME_QUALIFIED))) {
|
||||||
$currentClass[] = $text;
|
$currentClass[] = $text;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -300,9 +300,14 @@ PHP;
|
|||||||
<?php
|
<?php
|
||||||
namespace SilverStripe\Framework\Core;
|
namespace SilverStripe\Framework\Core;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class MyClass extends Base implements SomeService {
|
class MyClass extends Base implements SomeService {
|
||||||
public function getNewLines(\$class) {
|
public function getNewLines(\$class) {
|
||||||
if (!is_subclass_of(\$class, DataObject::class) || !Object::has_extension(\$class, Versioned::class)) {
|
if (
|
||||||
|
!is_subclass_of(\$class, DataObject::class)
|
||||||
|
|| !Object::has_extension(\$class, \SilverStripe\Versioned\Versioned::class)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _t(
|
return _t(
|
||||||
@ -331,6 +336,7 @@ class MyClass extends Base implements SomeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PHP;
|
PHP;
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'SilverStripe\\Framework\\Core\\MyClass.NEWLINES' => "New Lines",
|
'SilverStripe\\Framework\\Core\\MyClass.NEWLINES' => "New Lines",
|
||||||
|
Loading…
Reference in New Issue
Block a user