Skip to content

Commit 867e39c

Browse files
committed
fix: Update PHPStan type annotations in TestCase for improved type safety and clarity.
1 parent 0a1c5df commit 867e39c

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

tests/TestCase.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
use function dom_import_simplexml;
1717
use function str_replace;
1818

19+
/**
20+
* @phpstan-type DataSetType = list<
21+
* array{
22+
* id: int,
23+
* name: string,
24+
* tree: int,
25+
* type: 'multiple_tree'|'tree',
26+
* lft: int,
27+
* rgt: int,
28+
* depth: int,
29+
* }
30+
* >
31+
*/
1932
class TestCase extends \PHPUnit\Framework\TestCase
2033
{
2134
use SchemaBuilderTrait;
35+
2236
protected string $fixtureDirectory = __DIR__ . '/support/data/';
2337

2438
public function getDb(): Connection
@@ -27,9 +41,9 @@ public function getDb(): Connection
2741
}
2842

2943
/**
30-
* @phpstan-param array<
31-
* array{id: int, name: string, tree: int, type: string, lft: int, rgt: int, depth: int}
32-
* > $dataSet
44+
* @phpstan-import-type DataSetType from TestCase
45+
*
46+
* @phpstan-param DataSetType $dataSet
3347
*/
3448
protected function buildFlatXMLDataSet(array $dataSet): string
3549
{
@@ -111,17 +125,9 @@ protected function createDatabase(): void
111125
}
112126

113127
/**
114-
* @phpstan-return list<
115-
* array{
116-
* id: int,
117-
* name: string,
118-
* tree: int,
119-
* type: string,
120-
* lft: int,
121-
* rgt: int,
122-
* depth: int
123-
* }
124-
* >
128+
* @phpstan-import-type DataSetType from TestCase
129+
*
130+
* @phpstan-return DataSetType
125131
*/
126132
protected function getDataSet(): array
127133
{
@@ -142,17 +148,9 @@ protected function getDataSet(): array
142148
}
143149

144150
/**
145-
* @phpstan-return list<
146-
* array{
147-
* id: int,
148-
* name: string,
149-
* tree: int,
150-
* type: 'multiple_tree',
151-
* lft: int,
152-
* rgt: int,
153-
* depth: int,
154-
* }
155-
* >
151+
* @phpstan-import-type DataSetType from TestCase
152+
*
153+
* @phpstan-return DataSetType
156154
*/
157155
protected function getDataSetMultipleTree(): array
158156
{

0 commit comments

Comments
 (0)