Skip to content

Commit b9c85cf

Browse files
Merge pull request #19197 from MauricioFauth/localised-date-refactor
Change Util::localisedDate() to use DateTimeImmutable
2 parents 216663b + 220e32b commit b9c85cf

14 files changed

Lines changed: 115 additions & 310 deletions

File tree

phpstan-baseline.neon

Lines changed: 5 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,39 +2015,14 @@ parameters:
20152015
count: 4
20162016
path: src/Controllers/Database/StructureController.php
20172017

2018-
-
2019-
message: "#^Cannot access offset 'Check_time' on mixed\\.$#"
2020-
count: 1
2021-
path: src/Controllers/Database/StructureController.php
2022-
2023-
-
2024-
message: "#^Cannot access offset 'Collation' on mixed\\.$#"
2025-
count: 1
2026-
path: src/Controllers/Database/StructureController.php
2027-
2028-
-
2029-
message: "#^Cannot access offset 'Create_time' on mixed\\.$#"
2030-
count: 1
2031-
path: src/Controllers/Database/StructureController.php
2032-
2033-
-
2034-
message: "#^Cannot access offset 'ENGINE' on mixed\\.$#"
2035-
count: 2
2036-
path: src/Controllers/Database/StructureController.php
2037-
2038-
-
2039-
message: "#^Cannot access offset 'TABLE_COMMENT' on mixed\\.$#"
2040-
count: 1
2041-
path: src/Controllers/Database/StructureController.php
2042-
20432018
-
20442019
message: "#^Cannot access offset 'TABLE_NAME' on mixed\\.$#"
2045-
count: 12
2020+
count: 1
20462021
path: src/Controllers/Database/StructureController.php
20472022

20482023
-
20492024
message: "#^Cannot access offset 'TABLE_ROWS' on mixed\\.$#"
2050-
count: 3
2025+
count: 1
20512026
path: src/Controllers/Database/StructureController.php
20522027

20532028
-
@@ -2056,7 +2031,7 @@ parameters:
20562031
path: src/Controllers/Database/StructureController.php
20572032

20582033
-
2059-
message: "#^Cannot access offset 'Update_time' on mixed\\.$#"
2034+
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getStuffForEngineTypeTable\\(\\) should return array\\{array, string, string, string, string, int, bool, int\\} but returns array\\{mixed, mixed, mixed, mixed, mixed, mixed, bool, mixed\\}\\.$#"
20602035
count: 1
20612036
path: src/Controllers/Database/StructureController.php
20622037

@@ -2065,38 +2040,8 @@ parameters:
20652040
count: 1
20662041
path: src/Controllers/Database/StructureController.php
20672042

2068-
-
2069-
message: "#^Only booleans are allowed in &&, mixed given on the left side\\.$#"
2070-
count: 3
2071-
path: src/Controllers/Database/StructureController.php
2072-
2073-
-
2074-
message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
2075-
count: 3
2076-
path: src/Controllers/Database/StructureController.php
2077-
2078-
-
2079-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
2080-
count: 3
2081-
path: src/Controllers/Database/StructureController.php
2082-
2083-
-
2084-
message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#"
2085-
count: 3
2086-
path: src/Controllers/Database/StructureController.php
2087-
20882043
-
20892044
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
2090-
count: 2
2091-
path: src/Controllers/Database/StructureController.php
2092-
2093-
-
2094-
message: "#^Only booleans are allowed in \\|\\|, mixed given on the left side\\.$#"
2095-
count: 2
2096-
path: src/Controllers/Database/StructureController.php
2097-
2098-
-
2099-
message: "#^Only booleans are allowed in \\|\\|, mixed given on the right side\\.$#"
21002045
count: 1
21012046
path: src/Controllers/Database/StructureController.php
21022047

@@ -2105,21 +2050,6 @@ parameters:
21052050
count: 1
21062051
path: src/Controllers/Database/StructureController.php
21072052

2108-
-
2109-
message: "#^Parameter \\#1 \\$currentTable of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getStuffForEngineTypeTable\\(\\) expects array, mixed given\\.$#"
2110-
count: 1
2111-
path: src/Controllers/Database/StructureController.php
2112-
2113-
-
2114-
message: "#^Parameter \\#1 \\$currentTable of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:isRowCountApproximated\\(\\) expects array, mixed given\\.$#"
2115-
count: 1
2116-
path: src/Controllers/Database/StructureController.php
2117-
2118-
-
2119-
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, mixed given\\.$#"
2120-
count: 6
2121-
path: src/Controllers/Database/StructureController.php
2122-
21232053
-
21242054
message: "#^Parameter \\#1 \\$db of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:hasTable\\(\\) expects array, mixed given\\.$#"
21252055
count: 2
@@ -2150,11 +2080,6 @@ parameters:
21502080
count: 1
21512081
path: src/Controllers/Database/StructureController.php
21522082

2153-
-
2154-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, \\(int\\|false\\) given\\.$#"
2155-
count: 6
2156-
path: src/Controllers/Database/StructureController.php
2157-
21582083
-
21592084
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
21602085
count: 2
@@ -2170,21 +2095,11 @@ parameters:
21702095
count: 4
21712096
path: src/Controllers/Database/StructureController.php
21722097

2173-
-
2174-
message: "#^Parameter \\#2 \\$sumSize of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getStuffForEngineTypeTable\\(\\) expects int, mixed given\\.$#"
2175-
count: 1
2176-
path: src/Controllers/Database/StructureController.php
2177-
21782098
-
21792099
message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getReplicationStatus\\(\\) expects string, mixed given\\.$#"
21802100
count: 1
21812101
path: src/Controllers/Database/StructureController.php
21822102

2183-
-
2184-
message: "#^Parameter \\#2 \\$tableIsView of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:isRowCountApproximated\\(\\) expects bool, mixed given\\.$#"
2185-
count: 1
2186-
path: src/Controllers/Database/StructureController.php
2187-
21882103
-
21892104
message: "#^Parameter \\#2 \\$tableName of method PhpMyAdmin\\\\DatabaseInterface\\:\\:getTable\\(\\) expects string, mixed given\\.$#"
21902105
count: 4
@@ -2195,11 +2110,6 @@ parameters:
21952110
count: 1
21962111
path: src/Controllers/Database/StructureController.php
21972112

2198-
-
2199-
message: "#^Parameter \\#3 \\$overheadSize of method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getStuffForEngineTypeTable\\(\\) expects int, mixed given\\.$#"
2200-
count: 1
2201-
path: src/Controllers/Database/StructureController.php
2202-
22032113
-
22042114
message: "#^Cannot access offset 'back' on mixed\\.$#"
22052115
count: 1
@@ -2515,11 +2425,6 @@ parameters:
25152425
count: 1
25162426
path: src/Controllers/GitInfoController.php
25172427

2518-
-
2519-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, int\\|false given\\.$#"
2520-
count: 2
2521-
path: src/Controllers/GitInfoController.php
2522-
25232428
-
25242429
message: "#^Cannot access offset mixed on mixed\\.$#"
25252430
count: 1
@@ -5186,12 +5091,7 @@ parameters:
51865091
path: src/Controllers/Table/StructureController.php
51875092

51885093
-
5189-
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, int\\|string given\\.$#"
5190-
count: 3
5191-
path: src/Controllers/Table/StructureController.php
5192-
5193-
-
5194-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, int\\|false given\\.$#"
5094+
message: "#^Parameter \\#1 \\$datetime of class DateTimeImmutable constructor expects string, int\\|string given\\.$#"
51955095
count: 3
51965096
path: src/Controllers/Table/StructureController.php
51975097

@@ -10440,11 +10340,6 @@ parameters:
1044010340
count: 1
1044110341
path: src/Plugins/Export/ExportSql.php
1044210342

10443-
-
10444-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, int\\|false given\\.$#"
10445-
count: 3
10446-
path: src/Plugins/Export/ExportSql.php
10447-
1044810343
-
1044910344
message: "#^Parameter \\#2 \\$compat of method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportSql\\:\\:exportUseStatement\\(\\) expects string, mixed given\\.$#"
1045010345
count: 2
@@ -11461,7 +11356,7 @@ parameters:
1146111356
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
1146211357

1146311358
-
11464-
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, int\\|string given\\.$#"
11359+
message: "#^Parameter \\#1 \\$datetime of class DateTimeImmutable constructor expects string, int\\|string given\\.$#"
1146511360
count: 3
1146611361
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
1146711362

@@ -11470,11 +11365,6 @@ parameters:
1147011365
count: 3
1147111366
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
1147211367

11473-
-
11474-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, int\\|false given\\.$#"
11475-
count: 3
11476-
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
11477-
1147811368
-
1147911369
message: "#^Parameter \\#1 \\$txt of method TCPDF\\:\\:Bookmark\\(\\) expects string, mixed given\\.$#"
1148011370
count: 1
@@ -11680,21 +11570,6 @@ parameters:
1168011570
count: 2
1168111571
path: src/Plugins/Transformations/Abs/Bool2TextTransformationsPlugin.php
1168211572

11683-
-
11684-
message: "#^Binary operation \"\\-\\=\" between int\\<0, max\\>\\|string\\|false and int results in an error\\.$#"
11685-
count: 1
11686-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11687-
11688-
-
11689-
message: "#^Cannot cast mixed to int\\.$#"
11690-
count: 1
11691-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11692-
11693-
-
11694-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
11695-
count: 1
11696-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11697-
1169811573
-
1169911574
message: "#^Only booleans are allowed in &&, int\\|false given on the right side\\.$#"
1170011575
count: 1
@@ -11705,31 +11580,6 @@ parameters:
1170511580
count: 2
1170611581
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
1170711582

11708-
-
11709-
message: "#^Parameter \\#1 \\$format of function gmdate expects string, mixed given\\.$#"
11710-
count: 1
11711-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11712-
11713-
-
11714-
message: "#^Parameter \\#1 \\$string of function mb_strtolower expects string, mixed given\\.$#"
11715-
count: 1
11716-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11717-
11718-
-
11719-
message: "#^Parameter \\#1 \\$timestamp of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects int, mixed given\\.$#"
11720-
count: 1
11721-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11722-
11723-
-
11724-
message: "#^Parameter \\#2 \\$format of static method PhpMyAdmin\\\\Util\\:\\:localisedDate\\(\\) expects string, mixed given\\.$#"
11725-
count: 1
11726-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11727-
11728-
-
11729-
message: "#^Parameter \\#2 \\$timestamp of function gmdate expects int\\|null, mixed given\\.$#"
11730-
count: 1
11731-
path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
11732-
1173311583
-
1173411584
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
1173511585
count: 1

psalm-baseline.xml

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,12 +1469,6 @@
14691469
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
14701470
</InvalidArrayOffset>
14711471
<MixedArgument>
1472-
<code><![CDATA[$checkTime]]></code>
1473-
<code><![CDATA[$checkTimeAll]]></code>
1474-
<code><![CDATA[$createTime]]></code>
1475-
<code><![CDATA[$createTimeAll]]></code>
1476-
<code><![CDATA[$currentTable]]></code>
1477-
<code><![CDATA[$currentTable]]></code>
14781472
<code><![CDATA[$currentTable['Collation']]]></code>
14791473
<code><![CDATA[$currentTable['Data_free']]]></code>
14801474
<code><![CDATA[$currentTable['Name']]]></code>
@@ -1489,7 +1483,6 @@
14891483
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
14901484
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
14911485
<code><![CDATA[$dbTable]]></code>
1492-
<code><![CDATA[$overheadSize]]></code>
14931486
<code><![CDATA[$replicaInfo['Do_DB']]]></code>
14941487
<code><![CDATA[$replicaInfo['Do_DB']]]></code>
14951488
<code><![CDATA[$replicaInfo['Do_DB']]]></code>
@@ -1499,41 +1492,18 @@
14991492
<code><![CDATA[$replicaInfo['Wild_Do_Table']]]></code>
15001493
<code><![CDATA[$replicaInfo['Wild_Ignore_Table']]]></code>
15011494
<code><![CDATA[$request->getParsedBodyParam('primary_connection')]]></code>
1502-
<code><![CDATA[$sumSize]]></code>
1503-
<code><![CDATA[$tableIsView]]></code>
15041495
<code><![CDATA[$truename]]></code>
1505-
<code><![CDATA[$updateTime]]></code>
1506-
<code><![CDATA[$updateTimeAll]]></code>
15071496
</MixedArgument>
15081497
<MixedArrayAccess>
1509-
<code><![CDATA[$currentTable['Check_time']]]></code>
1510-
<code><![CDATA[$currentTable['Collation']]]></code>
1511-
<code><![CDATA[$currentTable['Create_time']]]></code>
1512-
<code><![CDATA[$currentTable['ENGINE']]]></code>
1513-
<code><![CDATA[$currentTable['ENGINE']]]></code>
1514-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
15151498
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1516-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1517-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1518-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1519-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1520-
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
1521-
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
1522-
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
15231499
<code><![CDATA[$currentTable['TABLE_TYPE']]]></code>
1524-
<code><![CDATA[$currentTable['Update_time']]]></code>
15251500
</MixedArrayAccess>
15261501
<MixedArrayAssignment>
15271502
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
15281503
</MixedArrayAssignment>
15291504
<MixedAssignment>
15301505
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
15311506
<code><![CDATA[$charset]]></code>
1532-
<code><![CDATA[$checkTime]]></code>
1533-
<code><![CDATA[$checkTimeAll]]></code>
1534-
<code><![CDATA[$createTime]]></code>
1535-
<code><![CDATA[$createTimeAll]]></code>
1536-
<code><![CDATA[$currentTable]]></code>
15371507
<code><![CDATA[$dbTable]]></code>
15381508
<code><![CDATA[$overheadSize]]></code>
15391509
<code><![CDATA[$searchDb]]></code>
@@ -1542,8 +1512,6 @@
15421512
<code><![CDATA[$searchTable]]></code>
15431513
<code><![CDATA[$sumEntries]]></code>
15441514
<code><![CDATA[$truename]]></code>
1545-
<code><![CDATA[$updateTime]]></code>
1546-
<code><![CDATA[$updateTimeAll]]></code>
15471515
</MixedAssignment>
15481516
<MixedMethodCall>
15491517
<code><![CDATA[getCharset]]></code>
@@ -1556,11 +1524,19 @@
15561524
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
15571525
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
15581526
</MixedOperand>
1559-
<RiskyTruthyFalsyComparison>
1560-
<code><![CDATA[$checkTime]]></code>
1561-
<code><![CDATA[$createTime]]></code>
1562-
<code><![CDATA[$updateTime]]></code>
1563-
</RiskyTruthyFalsyComparison>
1527+
<MixedReturnTypeCoercion>
1528+
<code><![CDATA[[
1529+
$currentTable,
1530+
$formattedSize,
1531+
$unit,
1532+
$formattedOverhead,
1533+
$overheadUnit,
1534+
$overheadSize,
1535+
$tableIsView,
1536+
$sumSize,
1537+
]]]></code>
1538+
<code><![CDATA[list{mixed[], string, string, string, string, int, bool, int}]]></code>
1539+
</MixedReturnTypeCoercion>
15641540
</file>
15651541
<file src="src/Controllers/Database/TrackingController.php">
15661542
<DeprecatedMethod>
@@ -9727,14 +9703,6 @@
97279703
<DeprecatedMethod>
97289704
<code><![CDATA[Config::getInstance()]]></code>
97299705
</DeprecatedMethod>
9730-
<InvalidOperand>
9731-
<code><![CDATA[$timestamp]]></code>
9732-
</InvalidOperand>
9733-
<MixedArgument>
9734-
<code><![CDATA[$options[1]]]></code>
9735-
<code><![CDATA[$options[1]]]></code>
9736-
<code><![CDATA[$options[2]]]></code>
9737-
</MixedArgument>
97389706
</file>
97399707
<file src="src/Plugins/Transformations/Abs/DownloadTransformationsPlugin.php">
97409708
<InvalidArrayOffset>

0 commit comments

Comments
 (0)