Skip to content

Commit 3a0f08e

Browse files
matijn-madenicolas-grekas
authored andcommitted
[TypeInfo] Simple array should be array type
1 parent e358179 commit 3a0f08e

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

Tests/Extractor/PhpStanExtractorTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,12 @@ public static function typesProvider(): iterable
691691
yield ['foo2', Type::float()];
692692
yield ['foo3', Type::callable()];
693693
yield ['foo5', Type::mixed()];
694-
yield ['files', Type::union(Type::list(Type::object(\SplFileInfo::class)), Type::resource()), null, null];
694+
yield ['files', Type::union(Type::array(Type::object(\SplFileInfo::class)), Type::resource()), null, null];
695695
yield ['bal', Type::object(\DateTimeImmutable::class)];
696696
yield ['parent', Type::object(ParentDummy::class)];
697-
yield ['collection', Type::list(Type::object(\DateTimeImmutable::class))];
698-
yield ['nestedCollection', Type::list(Type::list(Type::string()))];
699-
yield ['mixedCollection', Type::list()];
697+
yield ['collection', Type::array(Type::object(\DateTimeImmutable::class))];
698+
yield ['nestedCollection', Type::array(Type::array(Type::string()))];
699+
yield ['mixedCollection', Type::array(Type::mixed())];
700700
yield ['a', Type::int()];
701701
yield ['b', Type::nullable(Type::object(ParentDummy::class))];
702702
yield ['c', Type::nullable(Type::bool())];
@@ -707,7 +707,7 @@ public static function typesProvider(): iterable
707707
yield ['h', Type::nullable(Type::string())];
708708
yield ['i', Type::union(Type::int(), Type::string(), Type::null())];
709709
yield ['j', Type::nullable(Type::object(\DateTimeImmutable::class))];
710-
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::list(Type::int()))];
710+
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::array(Type::int()))];
711711
yield ['donotexist', null];
712712
yield ['staticGetter', null];
713713
yield ['staticSetter', null];
@@ -716,7 +716,7 @@ public static function typesProvider(): iterable
716716
yield ['arrayOfMixed', Type::dict(Type::mixed())];
717717
yield ['listOfStrings', Type::list(Type::string())];
718718
yield ['self', Type::object(Dummy::class)];
719-
yield ['rootDummyItems', Type::list(Type::object(RootDummyItem::class))];
719+
yield ['rootDummyItems', Type::array(Type::object(RootDummyItem::class))];
720720
yield ['rootDummyItem', Type::object(RootDummyItem::class)];
721721
yield ['collectionAsObject', Type::collection(Type::object(DummyCollection::class), Type::string(), Type::int())];
722722
}
@@ -767,12 +767,12 @@ public static function typesWithNoPrefixesProvider(): iterable
767767
yield ['foo2', Type::float()];
768768
yield ['foo3', Type::callable()];
769769
yield ['foo5', Type::mixed()];
770-
yield ['files', Type::union(Type::list(Type::object(\SplFileInfo::class)), Type::resource())];
770+
yield ['files', Type::union(Type::array(Type::object(\SplFileInfo::class)), Type::resource())];
771771
yield ['bal', Type::object(\DateTimeImmutable::class)];
772772
yield ['parent', Type::object(ParentDummy::class)];
773-
yield ['collection', Type::list(Type::object(\DateTimeImmutable::class))];
774-
yield ['nestedCollection', Type::list(Type::list(Type::string()))];
775-
yield ['mixedCollection', Type::list()];
773+
yield ['collection', Type::array(Type::object(\DateTimeImmutable::class))];
774+
yield ['nestedCollection', Type::array(Type::array(Type::string()))];
775+
yield ['mixedCollection', Type::array(Type::mixed())];
776776
yield ['a', null];
777777
yield ['b', null];
778778
yield ['c', null];
@@ -783,7 +783,7 @@ public static function typesWithNoPrefixesProvider(): iterable
783783
yield ['h', Type::nullable(Type::string())];
784784
yield ['i', Type::union(Type::int(), Type::string(), Type::null())];
785785
yield ['j', Type::nullable(Type::object(\DateTimeImmutable::class))];
786-
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::list(Type::int()))];
786+
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::array(Type::int()))];
787787
yield ['donotexist', null];
788788
yield ['staticGetter', null];
789789
yield ['staticSetter', null];
@@ -830,12 +830,12 @@ public static function typesWithCustomPrefixesProvider(): iterable
830830
yield ['foo2', Type::float()];
831831
yield ['foo3', Type::callable()];
832832
yield ['foo5', Type::mixed()];
833-
yield ['files', Type::union(Type::list(Type::object(\SplFileInfo::class)), Type::resource())];
833+
yield ['files', Type::union(Type::array(Type::object(\SplFileInfo::class)), Type::resource())];
834834
yield ['bal', Type::object(\DateTimeImmutable::class)];
835835
yield ['parent', Type::object(ParentDummy::class)];
836-
yield ['collection', Type::list(Type::object(\DateTimeImmutable::class))];
837-
yield ['nestedCollection', Type::list(Type::list(Type::string()))];
838-
yield ['mixedCollection', Type::list()];
836+
yield ['collection', Type::array(Type::object(\DateTimeImmutable::class))];
837+
yield ['nestedCollection', Type::array(Type::array(Type::string()))];
838+
yield ['mixedCollection', Type::array(Type::mixed())];
839839
yield ['a', null];
840840
yield ['b', null];
841841
yield ['c', Type::nullable(Type::bool())];
@@ -846,7 +846,7 @@ public static function typesWithCustomPrefixesProvider(): iterable
846846
yield ['h', Type::nullable(Type::string())];
847847
yield ['i', Type::union(Type::int(), Type::string(), Type::null())];
848848
yield ['j', Type::nullable(Type::object(\DateTimeImmutable::class))];
849-
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::list(Type::int()))];
849+
yield ['nullableCollectionOfNonNullableElements', Type::nullable(Type::array(Type::int()))];
850850
yield ['nonNullableCollectionOfNullableElements', Type::array(Type::nullable(Type::int()))];
851851
yield ['nullableCollectionOfMultipleNonNullableElementTypes', Type::nullable(Type::array(Type::union(Type::int(), Type::string())))];
852852
yield ['donotexist', null];
@@ -976,16 +976,16 @@ public function testExtractorUnionTypes(string $property, ?Type $type)
976976
public static function unionTypesProvider(): iterable
977977
{
978978
yield ['a', Type::union(Type::string(), Type::int())];
979-
yield ['b', Type::list(Type::union(Type::string(), Type::int()))];
979+
yield ['b', Type::array(Type::union(Type::string(), Type::int()))];
980980
yield ['c', Type::array(Type::union(Type::string(), Type::int()))];
981981
yield ['d', Type::array(Type::array(Type::string()), Type::union(Type::string(), Type::int()))];
982982
yield ['e', Type::union(
983983
Type::generic(
984984
Type::object(Dummy::class),
985-
Type::array(Type::string(), Type::mixed()),
985+
Type::array(Type::string()),
986986
Type::union(
987987
Type::int(),
988-
Type::list(Type::collection(Type::object(\Traversable::class), Type::object(DefaultValue::class))),
988+
Type::array(Type::collection(Type::object(\Traversable::class), Type::object(DefaultValue::class))),
989989
),
990990
),
991991
Type::object(ParentDummy::class),

Tests/Fixtures/DummyUnionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DummyUnionType
4040
public $d;
4141

4242
/**
43-
* @var (Dummy<array<mixed, string>, (int | (\Traversable<DefaultValue>)[])> | ParentDummy | null)
43+
* @var (Dummy<array<string>, (int | (\Traversable<DefaultValue>)[])> | ParentDummy | null)
4444
*/
4545
public $e;
4646

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"php": ">=8.2",
2727
"symfony/deprecation-contracts": "^2.5|^3",
2828
"symfony/string": "^6.4|^7.0",
29-
"symfony/type-info": "^7.3.5"
29+
"symfony/type-info": "~7.3.8|^7.4.1"
3030
},
3131
"require-dev": {
3232
"symfony/serializer": "^6.4|^7.0",

0 commit comments

Comments
 (0)