Skip to content

Commit 9e53d69

Browse files
committed
Improve array type inference for some tests
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 646ba27 commit 9e53d69

25 files changed

Lines changed: 271 additions & 898 deletions

‎phpstan-baseline.neon‎

Lines changed: 46 additions & 531 deletions
Large diffs are not rendered by default.

‎psalm-baseline.xml‎

Lines changed: 11 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -14681,13 +14681,6 @@
1468114681
<code><![CDATA[$arr['sarr'][0][1][0]]]></code>
1468214682
<code><![CDATA[$arr['sarr'][0][2]]]></code>
1468314683
</MixedArrayAccess>
14684-
<MixedInferredReturnType>
14685-
<code>array</code>
14686-
<code>array</code>
14687-
<code>array</code>
14688-
<code>array</code>
14689-
<code>array</code>
14690-
</MixedInferredReturnType>
1469114684
</file>
1469214685
<file src="test/classes/Crypto/CryptoTest.php">
1469314686
<EmptyArrayAccess>
@@ -14762,19 +14755,6 @@
1476214755
<code>$result</code>
1476314756
</MixedAssignment>
1476414757
</file>
14765-
<file src="test/classes/Database/EventsTest.php">
14766-
<MixedAssignment>
14767-
<code>$_POST[$key]</code>
14768-
<code>$value</code>
14769-
</MixedAssignment>
14770-
<MixedInferredReturnType>
14771-
<code>array</code>
14772-
<code>array</code>
14773-
<code>array</code>
14774-
<code>array</code>
14775-
<code>array</code>
14776-
</MixedInferredReturnType>
14777-
</file>
1477814758
<file src="test/classes/Database/QbeTest.php">
1477914759
<MixedArgument>
1478014760
<code>$actual</code>
@@ -14796,24 +14776,6 @@
1479614776
<code>$value</code>
1479714777
</MixedAssignment>
1479814778
</file>
14799-
<file src="test/classes/Database/SearchTest.php">
14800-
<MixedInferredReturnType>
14801-
<code>array</code>
14802-
</MixedInferredReturnType>
14803-
</file>
14804-
<file src="test/classes/Database/TriggersTest.php">
14805-
<MixedAssignment>
14806-
<code>$_POST[$key]</code>
14807-
<code>$value</code>
14808-
</MixedAssignment>
14809-
<MixedInferredReturnType>
14810-
<code>array</code>
14811-
<code>array</code>
14812-
<code>array</code>
14813-
<code>array</code>
14814-
<code>array</code>
14815-
</MixedInferredReturnType>
14816-
</file>
1481714779
<file src="test/classes/DatabaseInterfaceTest.php">
1481814780
<MixedArgumentTypeCoercion>
1481914781
<code>$value</code>
@@ -14832,10 +14794,6 @@
1483214794
<code>escapeString</code>
1483314795
<code>escapeString</code>
1483414796
</DeprecatedMethod>
14835-
<MixedInferredReturnType>
14836-
<code>array</code>
14837-
<code>array</code>
14838-
</MixedInferredReturnType>
1483914797
</file>
1484014798
<file src="test/classes/Display/ResultsTest.php">
1484114799
<DocblockTypeContradiction>
@@ -14907,9 +14865,6 @@
1490714865
<InvalidScalarArgument>
1490814866
<code>$_SESSION</code>
1490914867
</InvalidScalarArgument>
14910-
<MixedInferredReturnType>
14911-
<code>array</code>
14912-
</MixedInferredReturnType>
1491314868
<RedundantCondition>
1491414869
<code>assertIsString</code>
1491514870
</RedundantCondition>
@@ -14968,107 +14923,24 @@
1496814923
<code>$privates</code>
1496914924
</PossiblyUnusedProperty>
1497014925
</file>
14971-
<file src="test/classes/Gis/GisFactoryTest.php">
14972-
<PossiblyInvalidArgument>
14973-
<code>testFactory</code>
14974-
<code>testFactory</code>
14975-
</PossiblyInvalidArgument>
14976-
</file>
14977-
<file src="test/classes/Gis/GisGeometryCollectionTest.php">
14978-
<MixedInferredReturnType>
14979-
<code>array</code>
14980-
<code>array</code>
14981-
<code>array</code>
14982-
<code>array</code>
14983-
</MixedInferredReturnType>
14984-
</file>
1498514926
<file src="test/classes/Gis/GisGeometryTest.php">
1498614927
<MixedAssignment>
1498714928
<code>$points</code>
1498814929
</MixedAssignment>
14989-
<MixedInferredReturnType>
14990-
<code>array</code>
14991-
<code>array</code>
14992-
<code>array</code>
14993-
</MixedInferredReturnType>
14994-
</file>
14995-
<file src="test/classes/Gis/GisLineStringTest.php">
14996-
<MixedInferredReturnType>
14997-
<code>array</code>
14998-
<code>array</code>
14999-
<code>array</code>
15000-
<code>array</code>
15001-
</MixedInferredReturnType>
15002-
</file>
15003-
<file src="test/classes/Gis/GisMultiLineStringTest.php">
15004-
<MixedInferredReturnType>
15005-
<code>array</code>
15006-
<code>array</code>
15007-
<code>array</code>
15008-
<code>array</code>
15009-
</MixedInferredReturnType>
15010-
</file>
15011-
<file src="test/classes/Gis/GisMultiPointTest.php">
15012-
<MixedInferredReturnType>
15013-
<code>array</code>
15014-
<code>array</code>
15015-
<code>array</code>
15016-
<code>array</code>
15017-
</MixedInferredReturnType>
15018-
</file>
15019-
<file src="test/classes/Gis/GisMultiPolygonTest.php">
15020-
<MixedArrayAssignment>
15021-
<code><![CDATA[$temp1[0]['MULTIPOLYGON']['no_of_polygons']]]></code>
15022-
<code><![CDATA[$temp2[0]['MULTIPOLYGON'][1]]]></code>
15023-
<code><![CDATA[$temp2[0]['MULTIPOLYGON'][1]['no_of_lines']]]></code>
15024-
<code><![CDATA[$temp3[0]['MULTIPOLYGON'][1]]]></code>
15025-
<code><![CDATA[$temp3[0]['MULTIPOLYGON'][1][0]]]></code>
15026-
<code><![CDATA[$temp3[0]['MULTIPOLYGON'][1][0]['no_of_points']]]></code>
15027-
</MixedArrayAssignment>
15028-
<MixedInferredReturnType>
15029-
<code>array</code>
15030-
<code>array</code>
15031-
<code>array</code>
15032-
<code>array</code>
15033-
<code>array</code>
15034-
</MixedInferredReturnType>
15035-
</file>
15036-
<file src="test/classes/Gis/GisPointTest.php">
15037-
<MixedInferredReturnType>
15038-
<code>array</code>
15039-
<code>array</code>
15040-
<code>array</code>
15041-
<code>array</code>
15042-
<code>array</code>
15043-
</MixedInferredReturnType>
1504414930
</file>
1504514931
<file src="test/classes/Gis/GisPolygonTest.php">
14932+
<LessSpecificReturnStatement>
14933+
<code><![CDATA[[[$temp['POLYGON'][0]], [$temp['POLYGON'][1]]]]]></code>
14934+
</LessSpecificReturnStatement>
1504614935
<MixedArrayAccess>
15047-
<code><![CDATA[$temp1[0]['POLYGON'][1]]]></code>
1504814936
<code><![CDATA[$temp1[0]['POLYGON'][1][3]]]></code>
1504914937
<code><![CDATA[$temp1[0]['POLYGON'][1][3]['y']]]></code>
15050-
<code><![CDATA[$temp['POLYGON'][0]]]></code>
15051-
<code><![CDATA[$temp['POLYGON'][0]]]></code>
1505214938
<code><![CDATA[$temp['POLYGON'][0]['no_of_points']]]></code>
15053-
<code><![CDATA[$temp['POLYGON'][1]]]></code>
15054-
<code><![CDATA[$temp['POLYGON'][1]]]></code>
1505514939
<code><![CDATA[$temp['POLYGON'][1]['no_of_points']]]></code>
1505614940
</MixedArrayAccess>
15057-
<MixedArrayAssignment>
15058-
<code><![CDATA[$temp2[0]['POLYGON']['no_of_lines']]]></code>
15059-
<code><![CDATA[$temp3[0]['POLYGON'][1]]]></code>
15060-
<code><![CDATA[$temp3[0]['POLYGON'][1]['no_of_points']]]></code>
15061-
</MixedArrayAssignment>
15062-
<MixedInferredReturnType>
15063-
<code>array</code>
15064-
<code>array</code>
15065-
<code>array</code>
15066-
<code>array</code>
15067-
<code>array</code>
15068-
<code>array</code>
15069-
<code>array</code>
15070-
<code>array</code>
15071-
</MixedInferredReturnType>
14941+
<MoreSpecificReturnType>
14942+
<code><![CDATA[array<array{mixed[]}>]]></code>
14943+
</MoreSpecificReturnType>
1507214944
</file>
1507314945
<file src="test/classes/Gis/GisVisualizationTest.php">
1507414946
<MixedAssignment>
@@ -15230,11 +15102,6 @@
1523015102
<code>array</code>
1523115103
</MixedInferredReturnType>
1523215104
</file>
15233-
<file src="test/classes/LinterTest.php">
15234-
<MixedInferredReturnType>
15235-
<code>array</code>
15236-
</MixedInferredReturnType>
15237-
</file>
1523815105
<file src="test/classes/MessageTest.php">
1523915106
<MixedInferredReturnType>
1524015107
<code>array</code>
@@ -15292,11 +15159,6 @@
1529215159
<code>assertIsString</code>
1529315160
</RedundantCondition>
1529415161
</file>
15295-
<file src="test/classes/Plugins/Auth/AuthenticationHttpTest.php">
15296-
<MixedInferredReturnType>
15297-
<code>array</code>
15298-
</MixedInferredReturnType>
15299-
</file>
1530015162
<file src="test/classes/Plugins/Export/ExportCodegenTest.php">
1530115163
<MixedAssignment>
1530215164
<code>$result</code>
@@ -15436,10 +15298,9 @@
1543615298
</MixedArgument>
1543715299
</file>
1543815300
<file src="test/classes/Plugins/Transformations/TransformationPluginsTest.php">
15439-
<MixedInferredReturnType>
15440-
<code>array</code>
15441-
<code>array</code>
15442-
</MixedInferredReturnType>
15301+
<InvalidArgument>
15302+
<code>testTransformation</code>
15303+
</InvalidArgument>
1544315304
</file>
1544415305
<file src="test/classes/PluginsTest.php">
1544515306
<InvalidReturnStatement>
@@ -15470,11 +15331,6 @@
1547015331
<code>assertIsArray</code>
1547115332
</RedundantCondition>
1547215333
</file>
15473-
<file src="test/classes/RoutingTest.php">
15474-
<MixedInferredReturnType>
15475-
<code>array</code>
15476-
</MixedInferredReturnType>
15477-
</file>
1547815334
<file src="test/classes/SanitizeTest.php">
1547915335
<MixedInferredReturnType>
1548015336
<code>array</code>
@@ -15591,7 +15447,7 @@
1559115447
<code>$val</code>
1559215448
</MixedAssignment>
1559315449
<MixedInferredReturnType>
15594-
<code>array</code>
15450+
<code><![CDATA[array<mixed>]]></code>
1559515451
<code>array|null</code>
1559615452
</MixedInferredReturnType>
1559715453
<MixedOperand>
@@ -15604,7 +15460,7 @@
1560415460
</MixedReturnStatement>
1560515461
<MixedReturnTypeCoercion>
1560615462
<code>$unUsed</code>
15607-
<code>array[]</code>
15463+
<code>mixed[][]</code>
1560815464
</MixedReturnTypeCoercion>
1560915465
<UnsupportedReferenceUsage>
1561015466
<code><![CDATA[$queryData = &$this->getQueryData($result)]]></code>
@@ -15653,9 +15509,6 @@
1565315509
<code>$sql</code>
1565415510
<code>$sql</code>
1565515511
</MixedAssignment>
15656-
<MixedInferredReturnType>
15657-
<code>array</code>
15658-
</MixedInferredReturnType>
1565915512
<MixedMethodCall>
1566015513
<code>method</code>
1566115514
<code>method</code>
@@ -15730,15 +15583,6 @@
1573015583
<code><![CDATA[$object->config['settings']['secret']]]></code>
1573115584
</MixedArgument>
1573215585
</file>
15733-
<file src="test/classes/TypesTest.php">
15734-
<MixedInferredReturnType>
15735-
<code>array</code>
15736-
<code>array</code>
15737-
<code>array</code>
15738-
<code>array</code>
15739-
<code>array</code>
15740-
</MixedInferredReturnType>
15741-
</file>
1574215586
<file src="test/classes/UserPasswordTest.php">
1574315587
<InvalidArgument>
1574415588
<code>testSetChangePasswordMsg</code>

‎test/classes/CoreTest.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ public function testArrayRemove(): void
235235
/**
236236
* Test for Core::checkPageValidity
237237
*
238-
* @param string $page Page
239-
* @param array $allowList Allow list
240-
* @param bool $include whether the page is going to be included
241-
* @param bool $expected Expected value
238+
* @param string $page Page
239+
* @param string[] $allowList Allow list
240+
* @param bool $include whether the page is going to be included
241+
* @param bool $expected Expected value
242242
*
243243
* @dataProvider providerTestGotoNowhere
244244
*/
@@ -250,7 +250,7 @@ public function testGotoNowhere(string $page, array $allowList, bool $include, b
250250
/**
251251
* Data provider for testGotoNowhere
252252
*
253-
* @return array
253+
* @return array<array{string, string[], bool, bool}>
254254
*/
255255
public static function providerTestGotoNowhere(): array
256256
{
@@ -284,7 +284,7 @@ public function testGetRealSize(string $size, int $expected): void
284284
/**
285285
* Data provider for testGetRealSize
286286
*
287-
* @return array
287+
* @return array<array{string, int}>
288288
*/
289289
public static function providerTestGetRealSize(): array
290290
{
@@ -333,7 +333,7 @@ public function testLinkURL(string $link, string $url): void
333333
/**
334334
* Data provider for testLinkURL
335335
*
336-
* @return array
336+
* @return array<array{string, string}>
337337
*/
338338
public static function providerTestLinkURL(): array
339339
{
@@ -492,7 +492,7 @@ public function testSafeUnserialize(string $data, mixed $expected): void
492492
/**
493493
* Test data provider
494494
*
495-
* @return array
495+
* @return array<array{string, mixed}>
496496
*/
497497
public static function provideTestSafeUnserialize(): array
498498
{
@@ -533,7 +533,7 @@ public function testSanitizeMySQLHost(string $host, string $expected): void
533533
/**
534534
* Test data provider
535535
*
536-
* @return array
536+
* @return array<array{string, string}>
537537
*/
538538
public static function provideTestSanitizeMySQLHost(): array
539539
{

0 commit comments

Comments
 (0)