1313
1414use function realpath ;
1515
16+ use const PHP_VERSION_ID ;
17+
1618/** @covers \PhpMyAdmin\SqlParser\Translator */
1719final class TranslatorTest extends TestCase
1820{
1921 public static function tearDownAfterClass (): void
2022 {
2123 $ loaderProperty = new ReflectionProperty (Translator::class, 'loader ' );
22- $ loaderProperty ->setAccessible (true );
24+ if (PHP_VERSION_ID < 80100 ) {
25+ $ loaderProperty ->setAccessible (true );
26+ }
27+
2328 $ loaderProperty ->setValue (null , null );
2429 $ translatorProperty = new ReflectionProperty (Translator::class, 'translator ' );
25- $ translatorProperty ->setAccessible (true );
30+ if (PHP_VERSION_ID < 80100 ) {
31+ $ translatorProperty ->setAccessible (true );
32+ }
33+
2634 $ translatorProperty ->setValue (null , null );
2735 Translator::setLocale ('en ' );
2836 }
@@ -46,10 +54,16 @@ public function testLocale(): void
4654 public function testLoad (?string $ globalLang , string $ locale , string $ expectedLocale ): void
4755 {
4856 $ loaderProperty = new ReflectionProperty (Translator::class, 'loader ' );
49- $ loaderProperty ->setAccessible (true );
57+ if (PHP_VERSION_ID < 80100 ) {
58+ $ loaderProperty ->setAccessible (true );
59+ }
60+
5061 $ loaderProperty ->setValue (null , null );
5162 $ translatorProperty = new ReflectionProperty (Translator::class, 'translator ' );
52- $ translatorProperty ->setAccessible (true );
63+ if (PHP_VERSION_ID < 80100 ) {
64+ $ translatorProperty ->setAccessible (true );
65+ }
66+
5367 $ translatorProperty ->setValue (null , null );
5468 $ GLOBALS ['lang ' ] = $ globalLang ;
5569 Translator::setLocale ($ locale );
@@ -62,16 +76,25 @@ public function testLoad(?string $globalLang, string $locale, string $expectedLo
6276 self ::assertInstanceOf (Loader::class, $ loader );
6377 $ loaderClass = new ReflectionClass (Loader::class);
6478 $ localeProperty = $ loaderClass ->getProperty ('locale ' );
65- $ localeProperty ->setAccessible (true );
79+ if (PHP_VERSION_ID < 80100 ) {
80+ $ localeProperty ->setAccessible (true );
81+ }
82+
6683 self ::assertSame ($ expectedLocale , $ localeProperty ->getValue ($ loader ));
6784 // Compatibility with MoTranslator < 5
6885 $ defaultDomainProperty = $ loaderClass ->hasProperty ('default_domain ' )
6986 ? $ loaderClass ->getProperty ('default_domain ' )
7087 : $ loaderClass ->getProperty ('defaultDomain ' );
71- $ defaultDomainProperty ->setAccessible (true );
88+ if (PHP_VERSION_ID < 80100 ) {
89+ $ defaultDomainProperty ->setAccessible (true );
90+ }
91+
7292 self ::assertSame ('sqlparser ' , $ defaultDomainProperty ->getValue ($ loader ));
7393 $ pathsProperty = $ loaderClass ->getProperty ('paths ' );
74- $ pathsProperty ->setAccessible (true );
94+ if (PHP_VERSION_ID < 80100 ) {
95+ $ pathsProperty ->setAccessible (true );
96+ }
97+
7598 self ::assertSame (
7699 ['' => './ ' , 'sqlparser ' => realpath (__DIR__ . '/../../src/ ' ) . '/../locale/ ' ],
77100 $ pathsProperty ->getValue ($ loader )
@@ -81,10 +104,16 @@ public function testLoad(?string $globalLang, string $locale, string $expectedLo
81104 public function testGettext (): void
82105 {
83106 $ loaderProperty = new ReflectionProperty (Translator::class, 'loader ' );
84- $ loaderProperty ->setAccessible (true );
107+ if (PHP_VERSION_ID < 80100 ) {
108+ $ loaderProperty ->setAccessible (true );
109+ }
110+
85111 $ loaderProperty ->setValue (null , null );
86112 $ translatorProperty = new ReflectionProperty (Translator::class, 'translator ' );
87- $ translatorProperty ->setAccessible (true );
113+ if (PHP_VERSION_ID < 80100 ) {
114+ $ translatorProperty ->setAccessible (true );
115+ }
116+
88117 $ translatorProperty ->setValue (null , null );
89118 Translator::setLocale ('pt_BR ' );
90119 self ::assertSame (
@@ -93,10 +122,16 @@ public function testGettext(): void
93122 );
94123
95124 $ loaderProperty = new ReflectionProperty (Translator::class, 'loader ' );
96- $ loaderProperty ->setAccessible (true );
125+ if (PHP_VERSION_ID < 80100 ) {
126+ $ loaderProperty ->setAccessible (true );
127+ }
128+
97129 $ loaderProperty ->setValue (null , null );
98130 $ translatorProperty = new ReflectionProperty (Translator::class, 'translator ' );
99- $ translatorProperty ->setAccessible (true );
131+ if (PHP_VERSION_ID < 80100 ) {
132+ $ translatorProperty ->setAccessible (true );
133+ }
134+
100135 $ translatorProperty ->setValue (null , null );
101136 Translator::setLocale ('en ' );
102137 self ::assertSame (
0 commit comments