Skip to content

Commit 563ec3a

Browse files
committed
Use type aliases to simplify expected values from JSON
1 parent 4cdf3ba commit 563ec3a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/Httpwg/HttpwgTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
use gapple\Tests\StructuredFields\RulesetTest;
1515
use ParagonIE\ConstantTime\Base32;
1616

17+
/**
18+
* @phpstan-type ExpectedParameters array<array{string, mixed}>
19+
* @phpstan-type ExpectedTuple array{mixed, ExpectedParameters}
20+
* @phpstan-type ExpectedInnerList array{array<ExpectedTuple>, ExpectedParameters}
21+
* @phpstan-type ExpectedOuterList array<ExpectedTuple>
22+
* @phpstan-type ExpectedDictionary array<array{string, ExpectedTuple}>
23+
*/
1724
abstract class HttpwgTest extends RulesetTest
1825
{
1926
/**
@@ -67,7 +74,7 @@ protected function rulesetDataProvider(): array
6774
/**
6875
* Convert the expected value of an item tuple.
6976
*
70-
* @param array{mixed, array<array{string, mixed}>} $item
77+
* @param ExpectedTuple $item
7178
* @return \gapple\StructuredFields\Item
7279
*/
7380
private static function convertExpectedItem(array $item): Item
@@ -78,7 +85,7 @@ private static function convertExpectedItem(array $item): Item
7885
/**
7986
* Convert the expected values of a parameters map.
8087
*
81-
* @param array<array{string, mixed}> $parameters
88+
* @param ExpectedParameters $parameters
8289
* @return Parameters
8390
*/
8491
private static function convertParameters(array $parameters): Parameters
@@ -100,7 +107,7 @@ private static function convertParameters(array $parameters): Parameters
100107
/**
101108
* Convert the expected values of an inner list tuple.
102109
*
103-
* @param array{array<array{mixed, array<array{string, mixed}>}>, array<array{string, mixed}>} $innerList
110+
* @param ExpectedInnerList $innerList
104111
* @return InnerList
105112
*/
106113
private static function convertInnerList(array $innerList): InnerList
@@ -117,7 +124,7 @@ private static function convertInnerList(array $innerList): InnerList
117124
/**
118125
* Convert the expected values of a list.
119126
*
120-
* @param array<array{mixed, array<array{string, mixed}>}> $list
127+
* @param ExpectedOuterList $list
121128
* @return OuterList
122129
*/
123130
private static function convertExpectedList(array $list): OuterList
@@ -138,7 +145,7 @@ private static function convertExpectedList(array $list): OuterList
138145
/**
139146
* Convert the expected values of a dictionary.
140147
*
141-
* @param array<array{string, array{mixed, array<array{string, mixed}>}}> $dictionary
148+
* @param ExpectedDictionary $dictionary
142149
* @return Dictionary
143150
*/
144151
private static function convertExpectedDictionary(array $dictionary): Dictionary

0 commit comments

Comments
 (0)