diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-09-09 15:04:21 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-09-09 15:04:21 +0300 |
commit | 746d1696b703b626bddb1e33c76992078f8454da (patch) | |
tree | 4ffc0ceadb66dc5bb6cab91e1f1a81df72c23509 | |
parent | d6b72de8aa4bc9e07869f75d4490d74deeb5b41a (diff) |
Improve type declaration of Index::getCompareData method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
-rw-r--r-- | libraries/classes/Index.php | 17 | ||||
-rw-r--r-- | libraries/classes/IndexColumn.php | 11 | ||||
-rw-r--r-- | phpstan-baseline.neon | 10 | ||||
-rw-r--r-- | test/classes/IndexColumnTest.php | 4 |
4 files changed, 25 insertions, 17 deletions
diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php index b664ee0d8c..94cb50b641 100644 --- a/libraries/classes/Index.php +++ b/libraries/classes/Index.php @@ -548,9 +548,20 @@ class Index /** * Gets the properties in an array for comparison purposes * - * @return array an array containing the properties of the index - */ - public function getCompareData() + * @return array<string, array<int, array<string, int|string|null>>|string|null> + * @psalm-return array{ + * Packed: string|null, + * Index_choice: string, + * columns?: list<array{ + * Column_name: string, + * Seq_in_index: int, + * Collation: string|null, + * Sub_part: int|null, + * Null: string + * }> + * } + */ + public function getCompareData(): array { $data = [ 'Packed' => $this->packed, diff --git a/libraries/classes/IndexColumn.php b/libraries/classes/IndexColumn.php index 4921002f32..adfca050c8 100644 --- a/libraries/classes/IndexColumn.php +++ b/libraries/classes/IndexColumn.php @@ -191,9 +191,16 @@ class IndexColumn /** * Gets the properties in an array for comparison purposes * - * @return array an array containing the properties of the index column + * @return array<string, int|string|null> + * @psalm-return array{ + * Column_name: string, + * Seq_in_index: int, + * Collation: string|null, + * Sub_part: int|null, + * Null: string + * } */ - public function getCompareData() + public function getCompareData(): array { return [ 'Column_name' => $this->name, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 10200ca77f..9cc1bc0c44 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4211,11 +4211,6 @@ parameters: path: libraries/classes/Index.php - - message: "#^Method PhpMyAdmin\\\\Index\\:\\:getCompareData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Index.php - - - message: "#^Method PhpMyAdmin\\\\Index\\:\\:set\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" count: 1 path: libraries/classes/Index.php @@ -4226,11 +4221,6 @@ parameters: path: libraries/classes/IndexColumn.php - - message: "#^Method PhpMyAdmin\\\\IndexColumn\\:\\:getCompareData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/IndexColumn.php - - - message: "#^Method PhpMyAdmin\\\\IndexColumn\\:\\:set\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" count: 1 path: libraries/classes/IndexColumn.php diff --git a/test/classes/IndexColumnTest.php b/test/classes/IndexColumnTest.php index 3ab72db02e..d82f60ab4e 100644 --- a/test/classes/IndexColumnTest.php +++ b/test/classes/IndexColumnTest.php @@ -45,7 +45,7 @@ class IndexColumnTest extends TestCase public function testGetCompareData(): void { - $this->assertEquals( + $this->assertSame( ['Column_name' => '', 'Seq_in_index' => 1, 'Collation' => null, 'Sub_part' => null, 'Null' => ''], $this->object->getCompareData() ); @@ -56,7 +56,7 @@ class IndexColumnTest extends TestCase 'Sub_part' => 2, 'Null' => 'NO', ]); - $this->assertEquals( + $this->assertSame( [ 'Column_name' => 'name', 'Seq_in_index' => 2, |