From 492a638c517268b6c88708ac5ab8648abe74942c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Fri, 12 Dec 2025 14:06:38 +0400 Subject: [PATCH] Improve the conversion of lists to strings --- src/PseudoTypes/NonEmptyArray.php | 2 +- src/Types/AbstractList.php | 2 +- src/Types/Iterable_.php | 2 +- tests/unit/CollectionResolverTest.php | 16 ++++++++-------- tests/unit/PseudoTypes/NonEmptyArrayTest.php | 2 +- tests/unit/Types/ArrayTest.php | 2 +- tests/unit/Types/IterableTest.php | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/PseudoTypes/NonEmptyArray.php b/src/PseudoTypes/NonEmptyArray.php index d3536862..4aa3720d 100644 --- a/src/PseudoTypes/NonEmptyArray.php +++ b/src/PseudoTypes/NonEmptyArray.php @@ -39,7 +39,7 @@ public function __toString(): string } if ($this->keyType) { - return 'non-empty-array<' . $this->keyType . ',' . $this->valueType . '>'; + return 'non-empty-array<' . $this->keyType . ', ' . $this->valueType . '>'; } return 'non-empty-array<' . $this->valueType . '>'; diff --git a/src/Types/AbstractList.php b/src/Types/AbstractList.php index 32eb0f23..83f032dd 100644 --- a/src/Types/AbstractList.php +++ b/src/Types/AbstractList.php @@ -81,7 +81,7 @@ public function __toString(): string } if ($this->keyType) { - return 'array<' . $this->keyType . ',' . $this->valueType . '>'; + return 'array<' . $this->keyType . ', ' . $this->valueType . '>'; } if ($this->valueType instanceof Compound) { diff --git a/src/Types/Iterable_.php b/src/Types/Iterable_.php index f7d2264b..3ac6ef6c 100644 --- a/src/Types/Iterable_.php +++ b/src/Types/Iterable_.php @@ -30,7 +30,7 @@ public function __toString(): string } if ($this->keyType) { - return 'iterable<' . $this->keyType . ',' . $this->valueType . '>'; + return 'iterable<' . $this->keyType . ', ' . $this->valueType . '>'; } return 'iterable<' . $this->valueType . '>'; diff --git a/tests/unit/CollectionResolverTest.php b/tests/unit/CollectionResolverTest.php index 815cb96c..407ae411 100644 --- a/tests/unit/CollectionResolverTest.php +++ b/tests/unit/CollectionResolverTest.php @@ -102,10 +102,10 @@ public function testResolvingArrayCollectionWithKey(): void { $fixture = new TypeResolver(); - $resolvedType = $fixture->resolve('array', new Context('')); + $resolvedType = $fixture->resolve('array', new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); - $this->assertSame('array', (string) $resolvedType); + $this->assertSame('array', (string) $resolvedType); $valueType = $resolvedType->getValueType(); @@ -127,7 +127,7 @@ public function testResolvingArrayCollectionWithKeyAndWhitespace(): void $resolvedType = $fixture->resolve('array', new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); - $this->assertSame('array', (string) $resolvedType); + $this->assertSame('array', (string) $resolvedType); $valueType = $resolvedType->getValueType(); @@ -170,16 +170,16 @@ public function testResolvingCollectionOfCollection(): void public function testGoodArrayCollectionKey(): void { $fixture = new TypeResolver(); - $resolvedType = $fixture->resolve('array', new Context('')); + $resolvedType = $fixture->resolve('array', new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); - $this->assertSame('array', (string) $resolvedType); + $this->assertSame('array', (string) $resolvedType); $fixture = new TypeResolver(); - $resolvedType = $fixture->resolve('array', new Context('')); + $resolvedType = $fixture->resolve('array', new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); - $this->assertSame('array', (string) $resolvedType); + $this->assertSame('array', (string) $resolvedType); } public function testMissingStartCollection(): void @@ -218,7 +218,7 @@ public function testResolvingCollectionAsArray(): void $resolvedType = $fixture->resolve('array', new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); - $this->assertSame('array', (string) $resolvedType); + $this->assertSame('array', (string) $resolvedType); $valueType = $resolvedType->getValueType(); diff --git a/tests/unit/PseudoTypes/NonEmptyArrayTest.php b/tests/unit/PseudoTypes/NonEmptyArrayTest.php index bc3bc184..50abda78 100644 --- a/tests/unit/PseudoTypes/NonEmptyArrayTest.php +++ b/tests/unit/PseudoTypes/NonEmptyArrayTest.php @@ -56,7 +56,7 @@ public function provideToStringData(): array new Compound([new Integer(), new String_()]), new String_() ), - 'non-empty-array', + 'non-empty-array', ], ]; } diff --git a/tests/unit/Types/ArrayTest.php b/tests/unit/Types/ArrayTest.php index 3c567dd6..8201f297 100644 --- a/tests/unit/Types/ArrayTest.php +++ b/tests/unit/Types/ArrayTest.php @@ -64,7 +64,7 @@ public function provideToStringData(): array 'array of mixed' => [new Array_(new Mixed_()), 'mixed[]'], 'array of single type' => [new Array_(new String_()), 'string[]'], 'array of compound type' => [new Array_(new Compound([new Integer(), new String_()])), '(int|string)[]'], - 'array with key type' => [new Array_(new String_(), new Integer()), 'array'], + 'array with key type' => [new Array_(new String_(), new Integer()), 'array'], ]; } } diff --git a/tests/unit/Types/IterableTest.php b/tests/unit/Types/IterableTest.php index d43216b9..7520ce36 100644 --- a/tests/unit/Types/IterableTest.php +++ b/tests/unit/Types/IterableTest.php @@ -38,7 +38,7 @@ public function provideToStringData(): array new Iterable_(new Compound([new Integer(), new String_()])), 'iterable', ], - 'iterable with key type' => [new Iterable_(new String_(), new Integer()), 'iterable'], + 'iterable with key type' => [new Iterable_(new String_(), new Integer()), 'iterable'], ]; } }