Skip to content

Commit 746d169

Browse files
committed
Improve type declaration of Index::getCompareData method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent d6b72de commit 746d169

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

libraries/classes/Index.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,20 @@ public function getColumns()
548548
/**
549549
* Gets the properties in an array for comparison purposes
550550
*
551-
* @return array an array containing the properties of the index
552-
*/
553-
public function getCompareData()
551+
* @return array<string, array<int, array<string, int|string|null>>|string|null>
552+
* @psalm-return array{
553+
* Packed: string|null,
554+
* Index_choice: string,
555+
* columns?: list<array{
556+
* Column_name: string,
557+
* Seq_in_index: int,
558+
* Collation: string|null,
559+
* Sub_part: int|null,
560+
* Null: string
561+
* }>
562+
* }
563+
*/
564+
public function getCompareData(): array
554565
{
555566
$data = [
556567
'Packed' => $this->packed,

libraries/classes/IndexColumn.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,16 @@ public function getSubPart()
191191
/**
192192
* Gets the properties in an array for comparison purposes
193193
*
194-
* @return array an array containing the properties of the index column
194+
* @return array<string, int|string|null>
195+
* @psalm-return array{
196+
* Column_name: string,
197+
* Seq_in_index: int,
198+
* Collation: string|null,
199+
* Sub_part: int|null,
200+
* Null: string
201+
* }
195202
*/
196-
public function getCompareData()
203+
public function getCompareData(): array
197204
{
198205
return [
199206
'Column_name' => $this->name,

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,11 +4210,6 @@ parameters:
42104210
count: 1
42114211
path: libraries/classes/Index.php
42124212

4213-
-
4214-
message: "#^Method PhpMyAdmin\\\\Index\\:\\:getCompareData\\(\\) return type has no value type specified in iterable type array\\.$#"
4215-
count: 1
4216-
path: libraries/classes/Index.php
4217-
42184213
-
42194214
message: "#^Method PhpMyAdmin\\\\Index\\:\\:set\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
42204215
count: 1
@@ -4225,11 +4220,6 @@ parameters:
42254220
count: 1
42264221
path: libraries/classes/IndexColumn.php
42274222

4228-
-
4229-
message: "#^Method PhpMyAdmin\\\\IndexColumn\\:\\:getCompareData\\(\\) return type has no value type specified in iterable type array\\.$#"
4230-
count: 1
4231-
path: libraries/classes/IndexColumn.php
4232-
42334223
-
42344224
message: "#^Method PhpMyAdmin\\\\IndexColumn\\:\\:set\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
42354225
count: 1

test/classes/IndexColumnTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testGetSubPart(): void
4545

4646
public function testGetCompareData(): void
4747
{
48-
$this->assertEquals(
48+
$this->assertSame(
4949
['Column_name' => '', 'Seq_in_index' => 1, 'Collation' => null, 'Sub_part' => null, 'Null' => ''],
5050
$this->object->getCompareData()
5151
);
@@ -56,7 +56,7 @@ public function testGetCompareData(): void
5656
'Sub_part' => 2,
5757
'Null' => 'NO',
5858
]);
59-
$this->assertEquals(
59+
$this->assertSame(
6060
[
6161
'Column_name' => 'name',
6262
'Seq_in_index' => 2,

0 commit comments

Comments
 (0)