File tree Expand file tree Collapse file tree
rules-tests/TypeDeclarationDocblocks/Rector
ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting
Class_/AddReturnDocblockDataProviderRector/Fixture
rules/Privatization/TypeManipulator
src/NodeTypeResolver/PHPStan/Type Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ class ComplexArray
88 {
99 return [
1010 'id ' => new \stdClass (),
11+ 'other ' => false ,
1112 'context ' => [
1213 'id ' => 1 ,
1314 'data ' => [
@@ -17,6 +18,11 @@ class ComplexArray
1718 ],
1819 'values ' => [
1920 'name ' => '111 ' ,
21+ 'age ' => 1 ,
22+ ],
23+ 'values_other ' => [
24+ 'name ' => '111 ' ,
25+ 'age ' => 1 ,
2026 ],
2127 ];
2228 }
@@ -37,6 +43,7 @@ class ComplexArray
3743 {
3844 return [
3945 'id ' => new \stdClass (),
46+ 'other ' => false ,
4047 'context ' => [
4148 'id ' => 1 ,
4249 'data ' => [
@@ -46,6 +53,11 @@ class ComplexArray
4653 ],
4754 'values ' => [
4855 'name ' => '111 ' ,
56+ 'age ' => 1 ,
57+ ],
58+ 'values_other ' => [
59+ 'name ' => '111 ' ,
60+ 'age ' => 1 ,
4961 ],
5062 ];
5163 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \AddReturnDocblockDataProviderRector \Fixture ;
4+
5+ use DateTime ;
6+ use DateTimeImmutable ;
7+ use PHPUnit \Framework \Attributes \DataProvider ;
8+ use PHPUnit \Framework \TestCase ;
9+
10+ final class MultiObjects extends TestCase
11+ {
12+ #[DataProvider('provideData ' )]
13+ public function testSomething ()
14+ {
15+ }
16+
17+ public static function provideData (): iterable
18+ {
19+ yield [[new DateTime (), 'format ' ]];
20+ yield [[new DateTimeImmutable (), 'format ' ]];
21+ }
22+ }
23+
24+ ?>
25+ -----
26+ <?php
27+
28+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \AddReturnDocblockDataProviderRector \Fixture ;
29+
30+ use DateTime ;
31+ use DateTimeImmutable ;
32+ use PHPUnit \Framework \Attributes \DataProvider ;
33+ use PHPUnit \Framework \TestCase ;
34+
35+ final class MultiObjects extends TestCase
36+ {
37+ #[DataProvider('provideData ' )]
38+ public function testSomething ()
39+ {
40+ }
41+
42+ /**
43+ * @return \Iterator<array<int, array<int, (\DateTime | \DateTimeImmutable | string)>>>
44+ */
45+ public static function provideData (): iterable
46+ {
47+ yield [[new DateTime (), 'format ' ]];
48+ yield [[new DateTimeImmutable (), 'format ' ]];
49+ }
50+ }
51+
52+ ?>
Original file line number Diff line number Diff line change 2727 /**
2828 * @var int
2929 */
30- private const MAX_PRINTED_UNION_DOC_LENGHT = 60 ;
30+ private const MAX_PRINTED_UNION_DOC_LENGHT = 77 ;
3131
3232 public function __construct (
3333 private TypeFactory $ typeFactory ,
Original file line number Diff line number Diff line change @@ -205,6 +205,16 @@ private function unwrapConstantArrayTypes(ConstantArrayType $constantArrayType):
205205 $ nestedFlattenKeyType = new MixedType ();
206206 }
207207
208+ if ($ nestedFlattenItemType instanceof ConstantArrayType) {
209+ $ innerArrayTypes = $ this ->unwrapConstantArrayTypes ($ nestedFlattenItemType );
210+ foreach ($ innerArrayTypes as $ innerArrayType ) {
211+ // preserve outer array -> inner array structure: array<outerKey, innerArray>
212+ $ unwrappedTypes [] = new ArrayType ($ nestedFlattenKeyType , $ innerArrayType );
213+ }
214+
215+ continue ;
216+ }
217+
208218 $ unwrappedTypes [] = new ArrayType ($ nestedFlattenKeyType , $ nestedFlattenItemType );
209219 }
210220
You can’t perform that action at this time.
0 commit comments