Skip to content

Commit 85262b4

Browse files
Merge pull request #19348 from MauricioFauth/i18n
Create I18n\TextDirection enum
2 parents 8b690ae + 258057a commit 85262b4

21 files changed

+173
-155
lines changed

phpstan-baseline.neon

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ parameters:
380380
path: src/Config.php
381381

382382
-
383-
message: "#^Parameter \\#1 \\$code of method PhpMyAdmin\\\\LanguageManager\\:\\:getLanguage\\(\\) expects string, mixed given\\.$#"
383+
message: "#^Parameter \\#1 \\$code of method PhpMyAdmin\\\\I18n\\\\LanguageManager\\:\\:getLanguage\\(\\) expects string, mixed given\\.$#"
384384
count: 1
385385
path: src/Config.php
386386

@@ -7854,6 +7854,69 @@ parameters:
78547854
count: 2
78557855
path: src/Http/ServerRequest.php
78567856

7857+
-
7858+
message: "#^Cannot access offset 'a_meta_dir' on mixed\\.$#"
7859+
count: 1
7860+
path: src/I18n/Language.php
7861+
7862+
-
7863+
message: "#^Cannot access offset 'a_meta_language' on mixed\\.$#"
7864+
count: 1
7865+
path: src/I18n/Language.php
7866+
7867+
-
7868+
message: "#^Cannot access offset 'w_page' on mixed\\.$#"
7869+
count: 1
7870+
path: src/I18n/Language.php
7871+
7872+
-
7873+
message: "#^Parameter \\#2 \\$path of function _bindtextdomain expects string, mixed given\\.$#"
7874+
count: 1
7875+
path: src/I18n/Language.php
7876+
7877+
-
7878+
message: """
7879+
#^Call to deprecated method getInstance\\(\\) of class PhpMyAdmin\\\\Config\\:
7880+
Use dependency injection instead\\.$#
7881+
"""
7882+
count: 1
7883+
path: src/I18n/LanguageManager.php
7884+
7885+
-
7886+
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
7887+
count: 5
7888+
path: src/I18n/LanguageManager.php
7889+
7890+
-
7891+
message: "#^Method PhpMyAdmin\\\\I18n\\\\LanguageManager\\:\\:availableLocales\\(\\) should return array\\<string\\> but returns array\\|false\\.$#"
7892+
count: 1
7893+
path: src/I18n/LanguageManager.php
7894+
7895+
-
7896+
message: "#^Parameter \\#1 \\$code of method PhpMyAdmin\\\\I18n\\\\LanguageManager\\:\\:getLanguage\\(\\) expects string, mixed given\\.$#"
7897+
count: 4
7898+
path: src/I18n/LanguageManager.php
7899+
7900+
-
7901+
message: "#^Parameter \\#1 \\$directory of function opendir expects string, mixed given\\.$#"
7902+
count: 1
7903+
path: src/I18n/LanguageManager.php
7904+
7905+
-
7906+
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, mixed given\\.$#"
7907+
count: 1
7908+
path: src/I18n/LanguageManager.php
7909+
7910+
-
7911+
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
7912+
count: 1
7913+
path: src/I18n/LanguageManager.php
7914+
7915+
-
7916+
message: "#^Property PhpMyAdmin\\\\I18n\\\\LanguageManager\\:\\:\\$availableLocales \\(array\\<string\\>\\) does not accept array\\|false\\.$#"
7917+
count: 1
7918+
path: src/I18n/LanguageManager.php
7919+
78577920
-
78587921
message: "#^Cannot access offset 'handler' on mixed\\.$#"
78597922
count: 2
@@ -8341,69 +8404,6 @@ parameters:
83418404
count: 1
83428405
path: src/IpAllowDeny.php
83438406

8344-
-
8345-
message: "#^Cannot access offset 'a_meta_dir' on mixed\\.$#"
8346-
count: 1
8347-
path: src/Language.php
8348-
8349-
-
8350-
message: "#^Cannot access offset 'a_meta_language' on mixed\\.$#"
8351-
count: 1
8352-
path: src/Language.php
8353-
8354-
-
8355-
message: "#^Cannot access offset 'w_page' on mixed\\.$#"
8356-
count: 1
8357-
path: src/Language.php
8358-
8359-
-
8360-
message: "#^Parameter \\#2 \\$path of function _bindtextdomain expects string, mixed given\\.$#"
8361-
count: 1
8362-
path: src/Language.php
8363-
8364-
-
8365-
message: """
8366-
#^Call to deprecated method getInstance\\(\\) of class PhpMyAdmin\\\\Config\\:
8367-
Use dependency injection instead\\.$#
8368-
"""
8369-
count: 1
8370-
path: src/LanguageManager.php
8371-
8372-
-
8373-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
8374-
count: 5
8375-
path: src/LanguageManager.php
8376-
8377-
-
8378-
message: "#^Method PhpMyAdmin\\\\LanguageManager\\:\\:availableLocales\\(\\) should return array\\<string\\> but returns array\\|false\\.$#"
8379-
count: 1
8380-
path: src/LanguageManager.php
8381-
8382-
-
8383-
message: "#^Parameter \\#1 \\$code of method PhpMyAdmin\\\\LanguageManager\\:\\:getLanguage\\(\\) expects string, mixed given\\.$#"
8384-
count: 4
8385-
path: src/LanguageManager.php
8386-
8387-
-
8388-
message: "#^Parameter \\#1 \\$directory of function opendir expects string, mixed given\\.$#"
8389-
count: 1
8390-
path: src/LanguageManager.php
8391-
8392-
-
8393-
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, mixed given\\.$#"
8394-
count: 1
8395-
path: src/LanguageManager.php
8396-
8397-
-
8398-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
8399-
count: 1
8400-
path: src/LanguageManager.php
8401-
8402-
-
8403-
message: "#^Property PhpMyAdmin\\\\LanguageManager\\:\\:\\$availableLocales \\(array\\<string\\>\\) does not accept array\\|false\\.$#"
8404-
count: 1
8405-
path: src/LanguageManager.php
8406-
84078407
-
84088408
message: "#^Binary operation \"\\+\" between int\\|string\\|null and int\\<0, max\\> results in an error\\.$#"
84098409
count: 1
@@ -16670,6 +16670,14 @@ parameters:
1667016670
count: 1
1667116671
path: tests/unit/Html/MySQLDocumentationTest.php
1667216672

16673+
-
16674+
message: """
16675+
#^Call to deprecated method getInstance\\(\\) of class PhpMyAdmin\\\\Config\\:
16676+
Use dependency injection instead\\.$#
16677+
"""
16678+
count: 6
16679+
path: tests/unit/I18n/LanguageTest.php
16680+
1667316681
-
1667416682
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#"
1667516683
count: 1
@@ -16757,14 +16765,6 @@ parameters:
1675716765
count: 2
1675816766
path: tests/unit/IpAllowDenyTest.php
1675916767

16760-
-
16761-
message: """
16762-
#^Call to deprecated method getInstance\\(\\) of class PhpMyAdmin\\\\Config\\:
16763-
Use dependency injection instead\\.$#
16764-
"""
16765-
count: 6
16766-
path: tests/unit/LanguageTest.php
16767-
1676816768
-
1676916769
message: """
1677016770
#^Call to deprecated method getInstance\\(\\) of class PhpMyAdmin\\\\Config\\:

psalm-baseline.xml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6152,6 +6152,46 @@
61526152
<code><![CDATA[$_REQUEST['goto']]]></code>
61536153
</PossiblyInvalidCast>
61546154
</file>
6155+
<file src="src/I18n/LanguageManager.php">
6156+
<DeprecatedMethod>
6157+
<code><![CDATA[Config::getInstance()]]></code>
6158+
</DeprecatedMethod>
6159+
<MixedArgument>
6160+
<code><![CDATA[$this->config->get('Lang')]]></code>
6161+
<code><![CDATA[$this->config->getCookie('pma_lang')]]></code>
6162+
</MixedArgument>
6163+
<MixedArrayOffset>
6164+
<code><![CDATA[$langs[$this->config->get('DefaultLang')]]]></code>
6165+
</MixedArrayOffset>
6166+
<MixedArrayTypeCoercion>
6167+
<code><![CDATA[$langs[$this->config->get('DefaultLang')]]]></code>
6168+
</MixedArrayTypeCoercion>
6169+
<MixedOperand>
6170+
<code><![CDATA[$this->config->get('FilterLanguages')]]></code>
6171+
</MixedOperand>
6172+
<PossiblyInvalidArgument>
6173+
<code><![CDATA[$_GET['lang']]]></code>
6174+
<code><![CDATA[$_POST['lang']]]></code>
6175+
</PossiblyInvalidArgument>
6176+
<PossiblyInvalidCast>
6177+
<code><![CDATA[$_GET['lang']]]></code>
6178+
<code><![CDATA[$_POST['lang']]]></code>
6179+
</PossiblyInvalidCast>
6180+
<PossiblyNullArgument>
6181+
<code><![CDATA[$this->config->get('Lang')]]></code>
6182+
<code><![CDATA[$this->config->getCookie('pma_lang')]]></code>
6183+
</PossiblyNullArgument>
6184+
<PossiblyNullArrayOffset>
6185+
<code><![CDATA[$langs]]></code>
6186+
</PossiblyNullArrayOffset>
6187+
<RiskyTruthyFalsyComparison>
6188+
<code><![CDATA[empty($_GET['lang'])]]></code>
6189+
<code><![CDATA[empty($_POST['lang'])]]></code>
6190+
<code><![CDATA[empty($this->config->get('FilterLanguages'))]]></code>
6191+
<code><![CDATA[empty($this->config->get('Lang'))]]></code>
6192+
<code><![CDATA[empty($this->config->getCookie('pma_lang'))]]></code>
6193+
</RiskyTruthyFalsyComparison>
6194+
</file>
61556195
<file src="src/Image/ImageWrapper.php">
61566196
<PossiblyUnusedReturnValue>
61576197
<code><![CDATA[bool]]></code>
@@ -6423,46 +6463,6 @@
64236463
<code><![CDATA[$ruleData[2]]]></code>
64246464
</PossiblyUndefinedArrayOffset>
64256465
</file>
6426-
<file src="src/LanguageManager.php">
6427-
<DeprecatedMethod>
6428-
<code><![CDATA[Config::getInstance()]]></code>
6429-
</DeprecatedMethod>
6430-
<MixedArgument>
6431-
<code><![CDATA[$this->config->get('Lang')]]></code>
6432-
<code><![CDATA[$this->config->getCookie('pma_lang')]]></code>
6433-
</MixedArgument>
6434-
<MixedArrayOffset>
6435-
<code><![CDATA[$langs[$this->config->get('DefaultLang')]]]></code>
6436-
</MixedArrayOffset>
6437-
<MixedArrayTypeCoercion>
6438-
<code><![CDATA[$langs[$this->config->get('DefaultLang')]]]></code>
6439-
</MixedArrayTypeCoercion>
6440-
<MixedOperand>
6441-
<code><![CDATA[$this->config->get('FilterLanguages')]]></code>
6442-
</MixedOperand>
6443-
<PossiblyInvalidArgument>
6444-
<code><![CDATA[$_GET['lang']]]></code>
6445-
<code><![CDATA[$_POST['lang']]]></code>
6446-
</PossiblyInvalidArgument>
6447-
<PossiblyInvalidCast>
6448-
<code><![CDATA[$_GET['lang']]]></code>
6449-
<code><![CDATA[$_POST['lang']]]></code>
6450-
</PossiblyInvalidCast>
6451-
<PossiblyNullArgument>
6452-
<code><![CDATA[$this->config->get('Lang')]]></code>
6453-
<code><![CDATA[$this->config->getCookie('pma_lang')]]></code>
6454-
</PossiblyNullArgument>
6455-
<PossiblyNullArrayOffset>
6456-
<code><![CDATA[$langs]]></code>
6457-
</PossiblyNullArrayOffset>
6458-
<RiskyTruthyFalsyComparison>
6459-
<code><![CDATA[empty($_GET['lang'])]]></code>
6460-
<code><![CDATA[empty($_POST['lang'])]]></code>
6461-
<code><![CDATA[empty($this->config->get('FilterLanguages'))]]></code>
6462-
<code><![CDATA[empty($this->config->get('Lang'))]]></code>
6463-
<code><![CDATA[empty($this->config->getCookie('pma_lang'))]]></code>
6464-
</RiskyTruthyFalsyComparison>
6465-
</file>
64666466
<file src="src/Linter.php">
64676467
<InvalidOperand>
64686468
<code><![CDATA[$error[3]]]></code>
@@ -13409,6 +13409,20 @@
1340913409
<code><![CDATA[providerForTestGetRoute]]></code>
1341013410
</PossiblyUnusedMethod>
1341113411
</file>
13412+
<file src="tests/unit/I18n/LanguageTest.php">
13413+
<DeprecatedMethod>
13414+
<code><![CDATA[Config::getInstance()]]></code>
13415+
<code><![CDATA[Config::getInstance()]]></code>
13416+
<code><![CDATA[Config::getInstance()]]></code>
13417+
<code><![CDATA[Config::getInstance()]]></code>
13418+
<code><![CDATA[Config::getInstance()]]></code>
13419+
<code><![CDATA[Config::getInstance()]]></code>
13420+
</DeprecatedMethod>
13421+
<PossiblyUnusedMethod>
13422+
<code><![CDATA[listLocales]]></code>
13423+
<code><![CDATA[selectDataProvider]]></code>
13424+
</PossiblyUnusedMethod>
13425+
</file>
1341213426
<file src="tests/unit/Identifiers/DatabaseNameTest.php">
1341313427
<PossiblyUnusedMethod>
1341413428
<code><![CDATA[providerForTestInvalidNames]]></code>
@@ -13572,20 +13586,6 @@
1357213586
<code><![CDATA[proxyIPs]]></code>
1357313587
</PossiblyUnusedMethod>
1357413588
</file>
13575-
<file src="tests/unit/LanguageTest.php">
13576-
<DeprecatedMethod>
13577-
<code><![CDATA[Config::getInstance()]]></code>
13578-
<code><![CDATA[Config::getInstance()]]></code>
13579-
<code><![CDATA[Config::getInstance()]]></code>
13580-
<code><![CDATA[Config::getInstance()]]></code>
13581-
<code><![CDATA[Config::getInstance()]]></code>
13582-
<code><![CDATA[Config::getInstance()]]></code>
13583-
</DeprecatedMethod>
13584-
<PossiblyUnusedMethod>
13585-
<code><![CDATA[listLocales]]></code>
13586-
<code><![CDATA[selectDataProvider]]></code>
13587-
</PossiblyUnusedMethod>
13588-
</file>
1358913589
<file src="tests/unit/LinterTest.php">
1359013590
<PossiblyUnusedMethod>
1359113591
<code><![CDATA[lintProvider]]></code>

src/Config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpMyAdmin\ConfigStorage\Relation;
1010
use PhpMyAdmin\Dbal\ConnectionType;
1111
use PhpMyAdmin\Exceptions\ConfigException;
12+
use PhpMyAdmin\I18n\LanguageManager;
1213
use PhpMyAdmin\Routing\Routing;
1314
use PhpMyAdmin\Theme\ThemeManager;
1415
use Throwable;

src/Controllers/HomeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
use PhpMyAdmin\Http\Factory\ResponseFactory;
1919
use PhpMyAdmin\Http\Response;
2020
use PhpMyAdmin\Http\ServerRequest;
21+
use PhpMyAdmin\I18n\LanguageManager;
2122
use PhpMyAdmin\Identifiers\DatabaseName;
2223
use PhpMyAdmin\Identifiers\TableName;
23-
use PhpMyAdmin\LanguageManager;
2424
use PhpMyAdmin\Message;
2525
use PhpMyAdmin\MessageType;
2626
use PhpMyAdmin\ResponseRenderer;

src/Controllers/Setup/HomeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use PhpMyAdmin\Http\Factory\ResponseFactory;
1212
use PhpMyAdmin\Http\Response;
1313
use PhpMyAdmin\Http\ServerRequest;
14-
use PhpMyAdmin\LanguageManager;
14+
use PhpMyAdmin\I18n\LanguageManager;
1515
use PhpMyAdmin\ResponseRenderer;
1616
use PhpMyAdmin\Setup\Index;
1717
use PhpMyAdmin\Setup\SetupHelper;

src/DatabaseInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PhpMyAdmin\Dbal\Warning;
1717
use PhpMyAdmin\Error\ErrorHandler;
1818
use PhpMyAdmin\Html\Generator;
19+
use PhpMyAdmin\I18n\LanguageManager;
1920
use PhpMyAdmin\Identifiers\DatabaseName;
2021
use PhpMyAdmin\Query\Cache;
2122
use PhpMyAdmin\Query\Compatibility;

src/Header.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Container\ContainerBuilder;
1212
use PhpMyAdmin\Html\Generator;
13+
use PhpMyAdmin\I18n\LanguageManager;
1314
use PhpMyAdmin\Navigation\Navigation;
1415
use PhpMyAdmin\Theme\ThemeManager;
1516

@@ -114,7 +115,7 @@ public function getJsParams(): array
114115
'table' => Current::$table,
115116
'db' => Current::$database,
116117
'token' => $_SESSION[' PMA_token '],
117-
'text_dir' => LanguageManager::$textDir,
118+
'text_dir' => LanguageManager::$textDirection->value,
118119
'LimitChars' => $this->config->settings['LimitChars'],
119120
'pftext' => $pftext,
120121
'confirm' => $this->config->settings['Confirm'],

src/Http/Middleware/LanguageLoading.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpMyAdmin\Http\Middleware;
66

7-
use PhpMyAdmin\LanguageManager;
7+
use PhpMyAdmin\I18n\LanguageManager;
88
use Psr\Http\Message\ResponseInterface;
99
use Psr\Http\Message\ServerRequestInterface;
1010
use Psr\Http\Server\MiddlewareInterface;

0 commit comments

Comments
 (0)