Skip to content

Commit a58ddf5

Browse files
ruudknicolas-grekas
authored andcommitted
[TypeInfo] Add space after glue comma
With this change, it will print a collection type as `array<key, value>` instead of `array<key,value>`. I believe it is more standard than without the space. It's also what Symfony itself does everywhere.
1 parent 4102229 commit a58ddf5

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testToString()
8989
$this->assertEquals('array<bool>', (string) $type);
9090

9191
$type = new CollectionType(new GenericType(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::bool()));
92-
$this->assertEquals('array<string,bool>', (string) $type);
92+
$this->assertEquals('array<string, bool>', (string) $type);
9393

9494
$type = new CollectionType(Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::bool()), isList: true);
9595
$this->assertEquals('list<bool>', (string) $type);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function testToString()
3131
$this->assertEquals('array<bool>', (string) $type);
3232

3333
$type = new GenericType(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::bool());
34-
$this->assertEquals('array<string,bool>', (string) $type);
34+
$this->assertEquals('array<string, bool>', (string) $type);
3535

3636
$type = new GenericType(Type::object(self::class), Type::union(Type::bool(), Type::string()), Type::int(), Type::float());
37-
$this->assertEquals(\sprintf('%s<bool|string,int,float>', self::class), (string) $type);
37+
$this->assertEquals(\sprintf('%s<bool|string, int, float>', self::class), (string) $type);
3838
}
3939

4040
public function testWrappedTypeIsSatisfiedBy()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __toString(): string
7272
$glue = '';
7373
foreach ($this->variableTypes as $t) {
7474
$variableTypesString .= $glue.$t;
75-
$glue = ',';
75+
$glue = ', ';
7676
}
7777

7878
return $typeString.'<'.$variableTypesString.'>';

src/Symfony/Component/TypeInfo/TypeFactoryTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public static function object(?string $className = null): BuiltinType|ObjectType
240240
* @param T $className
241241
* @param U|null $backingType
242242
*
243-
* @return ($className is class-string<\BackedEnum> ? ($backingType is U ? BackedEnumType<T,U> : BackedEnumType<T,BuiltinType<TypeIdentifier::INT>|BuiltinType<TypeIdentifier::STRING>>) : EnumType<T>))
243+
* @return ($className is class-string<\BackedEnum> ? ($backingType is U ? BackedEnumType<T, U> : BackedEnumType<T, BuiltinType<TypeIdentifier::INT>|BuiltinType<TypeIdentifier::STRING>>) : EnumType<T>))
244244
*/
245245
public static function enum(string $className, ?BuiltinType $backingType = null): EnumType
246246
{

0 commit comments

Comments
 (0)