Skip to content

Commit 84190bf

Browse files
bug #61375 [TypeInfo] Fix converting list to string (ruudk)
This PR was merged into the 7.3 branch. Discussion ---------- [TypeInfo] Fix converting list to string | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT It should print `list<type>` instead of `array<type>` Commits ------- 1e8e0af [TypeInfo] Fix converting list to string
2 parents b68c14b + 1e8e0af commit 84190bf

File tree

10 files changed

+36
-29
lines changed

10 files changed

+36
-29
lines changed

src/Symfony/Component/JsonStreamer/Tests/CacheWarmer/StreamerCacheWarmerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ public function testWarmUp()
5050

5151
$this->assertSame([
5252
\sprintf('%s/13791ba3dc4369dc488ec78466326979.json.php', $this->streamWritersDir),
53+
\sprintf('%s/30812f0966dfa8321b2976fca874c2c6.json.php', $this->streamWritersDir),
5354
\sprintf('%s/3d6bea319060b50305c349746ac6cabc.json.php', $this->streamWritersDir),
54-
\sprintf('%s/6f7c0ed338bb3b8730cc67686a91941b.json.php', $this->streamWritersDir),
5555
], glob($this->streamWritersDir.'/*'));
5656

5757
$this->assertSame([
5858
\sprintf('%s/13791ba3dc4369dc488ec78466326979.json.php', $this->streamReadersDir),
5959
\sprintf('%s/13791ba3dc4369dc488ec78466326979.json.stream.php', $this->streamReadersDir),
60+
\sprintf('%s/30812f0966dfa8321b2976fca874c2c6.json.php', $this->streamReadersDir),
61+
\sprintf('%s/30812f0966dfa8321b2976fca874c2c6.json.stream.php', $this->streamReadersDir),
6062
\sprintf('%s/3d6bea319060b50305c349746ac6cabc.json.php', $this->streamReadersDir),
6163
\sprintf('%s/3d6bea319060b50305c349746ac6cabc.json.stream.php', $this->streamReadersDir),
62-
\sprintf('%s/6f7c0ed338bb3b8730cc67686a91941b.json.php', $this->streamReadersDir),
63-
\sprintf('%s/6f7c0ed338bb3b8730cc67686a91941b.json.stream.php', $this->streamReadersDir),
6464
], glob($this->streamReadersDir.'/*'));
6565
}
6666

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/list.stream.php

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/nullable_object_list.php

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/nullable_object_list.stream.php

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/object_list.php

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/object_list.stream.php

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/union.php

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/union.stream.php

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/TypeInfo/Tests/Type/CollectionTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public function testToString()
9090

9191
$type = new CollectionType(new GenericType(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::bool()));
9292
$this->assertEquals('array<string,bool>', (string) $type);
93+
94+
$type = new CollectionType(Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::bool()), isList: true);
95+
$this->assertEquals('list<bool>', (string) $type);
9396
}
9497

9598
public function testAccepts()

src/Symfony/Component/TypeInfo/Type/CollectionType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ public function accepts(mixed $value): bool
179179

180180
public function __toString(): string
181181
{
182+
if ($this->isList && $this->type->isIdentifiedBy(TypeIdentifier::ARRAY)) {
183+
return 'list<'.$this->getCollectionValueType().'>';
184+
}
185+
182186
return (string) $this->type;
183187
}
184188
}

0 commit comments

Comments
 (0)