Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25c905a

Browse files
committed
[TypeInfo] Fix converting list to string
It should print `list<type>` instead of `array<type>`
1 parent986d4e2 commit25c905a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎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 =newCollectionType(newGenericType(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::bool()));
9292
$this->assertEquals('array<string,bool>', (string)$type);
93+
94+
$type =newCollectionType(Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::bool()), isList:true);
95+
$this->assertEquals('list<bool>', (string)$type);
9396
}
9497

9598
publicfunctiontestAccepts()

‎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
publicfunction__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)

[8]ページ先頭

©2009-2025 Movatter.jp