From 9a58eea36e171cae999cc8ae0875e43da323f19b 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: Sun, 30 Nov 2025 21:59:10 +0400 Subject: [PATCH 1/5] Add support for compound FQSEN to `class-string` and `interface-string` --- src/PseudoTypes/ClassString.php | 21 ++++----- src/PseudoTypes/InterfaceString.php | 21 ++++----- src/TypeResolver.php | 45 ++++++++++--------- tests/unit/PseudoTypes/ClassStringTest.php | 10 +++-- .../unit/PseudoTypes/InterfaceStringTest.php | 10 +++-- tests/unit/TypeResolverTest.php | 16 ++++++- 6 files changed, 72 insertions(+), 51 deletions(-) diff --git a/src/PseudoTypes/ClassString.php b/src/PseudoTypes/ClassString.php index 02ee2b8e..9422e945 100644 --- a/src/PseudoTypes/ClassString.php +++ b/src/PseudoTypes/ClassString.php @@ -25,15 +25,12 @@ */ final class ClassString extends String_ implements PseudoType { - /** @var Fqsen|null */ - private $fqsen; + /** @var Fqsen[] */ + private $fqsens; - /** - * Initializes this representation of a class string with the given Fqsen. - */ - public function __construct(?Fqsen $fqsen = null) + public function __construct(Fqsen ...$fqsens) { - $this->fqsen = $fqsen; + $this->fqsens = $fqsens; } public function underlyingType(): Type @@ -42,11 +39,11 @@ public function underlyingType(): Type } /** - * Returns the FQSEN associated with this object. + * @return Fqsen[] */ - public function getFqsen(): ?Fqsen + public function getFqsens(): array { - return $this->fqsen; + return $this->fqsens; } /** @@ -54,10 +51,10 @@ public function getFqsen(): ?Fqsen */ public function __toString(): string { - if ($this->fqsen === null) { + if (!$this->fqsens) { return 'class-string'; } - return 'class-string<' . (string) $this->fqsen . '>'; + return 'class-string<' . implode('|', $this->fqsens) . '>'; } } diff --git a/src/PseudoTypes/InterfaceString.php b/src/PseudoTypes/InterfaceString.php index 89248144..768bd9e4 100644 --- a/src/PseudoTypes/InterfaceString.php +++ b/src/PseudoTypes/InterfaceString.php @@ -25,15 +25,12 @@ */ final class InterfaceString extends String_ implements PseudoType { - /** @var Fqsen|null */ - private $fqsen; + /** @var Fqsen[] */ + private $fqsens; - /** - * Initializes this representation of a class string with the given Fqsen. - */ - public function __construct(?Fqsen $fqsen = null) + public function __construct(Fqsen ...$fqsens) { - $this->fqsen = $fqsen; + $this->fqsens = $fqsens; } public function underlyingType(): Type @@ -42,11 +39,11 @@ public function underlyingType(): Type } /** - * Returns the FQSEN associated with this object. + * @return Fqsen[] */ - public function getFqsen(): ?Fqsen + public function getFqsens(): array { - return $this->fqsen; + return $this->fqsens; } /** @@ -54,10 +51,10 @@ public function getFqsen(): ?Fqsen */ public function __toString(): string { - if ($this->fqsen === null) { + if (!$this->fqsens) { return 'interface-string'; } - return 'interface-string<' . (string) $this->fqsen . '>'; + return 'interface-string<' . implode('|', $this->fqsens) . '>'; } } diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 7f60de4b..2faa9ca3 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -404,28 +404,10 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ return new NonEmptyArray(...$genericTypes); case 'class-string': - $subType = $this->createType($type->genericTypes[0], $context); - if (!$subType instanceof Object_ || $subType->getFqsen() === null) { - throw new RuntimeException( - $subType . ' is not a class string' - ); - } - - return new ClassString( - $subType->getFqsen() - ); + return new ClassString(...$this->getFqsensByTypeNode($type->genericTypes[0], $context)); case 'interface-string': - $subType = $this->createType($type->genericTypes[0], $context); - if (!$subType instanceof Object_ || $subType->getFqsen() === null) { - throw new RuntimeException( - $subType . ' is not a class string' - ); - } - - return new InterfaceString( - $subType->getFqsen() - ); + return new InterfaceString(...$this->getFqsensByTypeNode($type->genericTypes[0], $context)); case 'list': return new List_( @@ -673,6 +655,29 @@ private function parse(TokenIterator $tokenIterator): TypeNode return $ast; } + /** + * @return Fqsen[] + */ + private function getFqsensByTypeNode(TypeNode $node, Context $context): array + { + $nodes = [$node]; + if ($node instanceof UnionTypeNode) { + $nodes = $node->types; + } + + return array_map( + function (TypeNode $node) use ($context): Fqsen { + $type = $this->createType($node, $context); + if ($type instanceof Object_ === false || $type->getFqsen() === null) { + throw new RuntimeException($type . ' is not a class or interface'); + } + + return $type->getFqsen(); + }, + $nodes + ); + } + /** * @param TypeNode[] $nodes * diff --git a/tests/unit/PseudoTypes/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php index b83ca5c4..904ac6ab 100644 --- a/tests/unit/PseudoTypes/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -25,19 +25,23 @@ class ClassStringTest extends TestCase * @dataProvider provideClassStrings * @covers ::__toString */ - public function testClassStringStringifyCorrectly(ClassString $array, string $expectedString): void + public function testClassStringStringifyCorrectly(ClassString $type, string $expectedString): void { - $this->assertSame($expectedString, (string) $array); + $this->assertSame($expectedString, (string) $type); } /** - * @return mixed[] + * @return array */ public function provideClassStrings(): array { return [ 'generic class string' => [new ClassString(), 'class-string'], 'typed class string' => [new ClassString(new Fqsen('\Foo\Bar')), 'class-string<\Foo\Bar>'], + 'more than one class' => [ + new ClassString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), + 'class-string<\Foo\Bar|\Foo\Barrr>' + ], ]; } } diff --git a/tests/unit/PseudoTypes/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php index 92e2ee21..a8d57543 100644 --- a/tests/unit/PseudoTypes/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -25,19 +25,23 @@ class InterfaceStringTest extends TestCase * @dataProvider provideInterfaceStrings * @covers ::__toString */ - public function testInterfaceStringStringifyCorrectly(InterfaceString $array, string $expectedString): void + public function testInterfaceStringStringifyCorrectly(InterfaceString $type, string $expectedString): void { - $this->assertSame($expectedString, (string) $array); + $this->assertSame($expectedString, (string) $type); } /** - * @return mixed[] + * @return array */ public function provideInterfaceStrings(): array { return [ 'generic interface string' => [new InterfaceString(), 'interface-string'], 'typed interface string' => [new InterfaceString(new Fqsen('\Foo\Bar')), 'interface-string<\Foo\Bar>'], + 'more than one class' => [ + new InterfaceString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), + 'interface-string<\Foo\Bar|\Foo\Barrr>' + ], ]; } } diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 3fc314cd..3e65c6f2 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -1142,16 +1142,30 @@ public function genericsProvider(): array ], [ 'class-string', - new ClassString(null), + new ClassString(), ], [ 'class-string', new ClassString(new Fqsen('\\phpDocumentor\\Foo')), ], + [ + 'class-string', + new ClassString( + new Fqsen('\\phpDocumentor\\Foo'), + new Fqsen('\\phpDocumentor\\Bar') + ), + ], [ 'interface-string', new InterfaceString(new Fqsen('\\phpDocumentor\\Foo')), ], + [ + 'interface-string', + new InterfaceString( + new Fqsen('\\phpDocumentor\\Foo'), + new Fqsen('\\phpDocumentor\\Bar'), + ), + ], [ 'List', new List_(new Object_(new Fqsen('\\phpDocumentor\\Foo'))), From 336bc493c7208e9f01e4e0c9009b9989200282fa 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: Sun, 30 Nov 2025 22:01:32 +0400 Subject: [PATCH 2/5] Add tests --- tests/unit/TypeResolverTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 3e65c6f2..3ef4419b 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -842,6 +842,7 @@ public function provideClassStrings(): array ['class-string<\phpDocumentor\Reflection>', false], ['class-string<\phpDocumentor\Reflection\DocBlock>', false], ['class-string', true], + ['class-string<\Foo&\Bar>', true], ]; } @@ -856,6 +857,7 @@ public function provideInterfaceStrings(): array ['interface-string<\phpDocumentor\Reflection>', false], ['interface-string<\phpDocumentor\Reflection\DocBlock>', false], ['interface-string', true], + ['interface-string<\Foo&\Bar>', true], ]; } @@ -1155,6 +1157,10 @@ public function genericsProvider(): array new Fqsen('\\phpDocumentor\\Bar') ), ], + [ + 'interface-string', + new InterfaceString(), + ], [ 'interface-string', new InterfaceString(new Fqsen('\\phpDocumentor\\Foo')), From afa9b910a30736e53a0ec6caf9edc5e30cbefe42 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: Sun, 30 Nov 2025 22:03:20 +0400 Subject: [PATCH 3/5] Fix CS --- src/PseudoTypes/ClassString.php | 2 ++ src/PseudoTypes/InterfaceString.php | 2 ++ tests/unit/PseudoTypes/ClassStringTest.php | 2 +- tests/unit/PseudoTypes/InterfaceStringTest.php | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PseudoTypes/ClassString.php b/src/PseudoTypes/ClassString.php index 9422e945..3ddb6cbe 100644 --- a/src/PseudoTypes/ClassString.php +++ b/src/PseudoTypes/ClassString.php @@ -18,6 +18,8 @@ use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\String_; +use function implode; + /** * Value Object representing the type 'class-string'. * diff --git a/src/PseudoTypes/InterfaceString.php b/src/PseudoTypes/InterfaceString.php index 768bd9e4..da34e44f 100644 --- a/src/PseudoTypes/InterfaceString.php +++ b/src/PseudoTypes/InterfaceString.php @@ -18,6 +18,8 @@ use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\String_; +use function implode; + /** * Value Object representing the type `interface-string`. * diff --git a/tests/unit/PseudoTypes/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php index 904ac6ab..c64f16e5 100644 --- a/tests/unit/PseudoTypes/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -40,7 +40,7 @@ public function provideClassStrings(): array 'typed class string' => [new ClassString(new Fqsen('\Foo\Bar')), 'class-string<\Foo\Bar>'], 'more than one class' => [ new ClassString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), - 'class-string<\Foo\Bar|\Foo\Barrr>' + 'class-string<\Foo\Bar|\Foo\Barrr>', ], ]; } diff --git a/tests/unit/PseudoTypes/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php index a8d57543..6c62d731 100644 --- a/tests/unit/PseudoTypes/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -40,7 +40,7 @@ public function provideInterfaceStrings(): array 'typed interface string' => [new InterfaceString(new Fqsen('\Foo\Bar')), 'interface-string<\Foo\Bar>'], 'more than one class' => [ new InterfaceString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), - 'interface-string<\Foo\Bar|\Foo\Barrr>' + 'interface-string<\Foo\Bar|\Foo\Barrr>', ], ]; } From 86e555c861a70b544da396fdbb6ca9b7f48807e0 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: Sun, 30 Nov 2025 23:34:58 +0400 Subject: [PATCH 4/5] Add support for any generics to `class-string` and `interface-string` --- src/PseudoTypes/ClassString.php | 22 ++--- src/PseudoTypes/InterfaceString.php | 22 ++--- src/TypeResolver.php | 27 +----- tests/unit/PseudoTypes/ClassStringTest.php | 14 ++- .../unit/PseudoTypes/InterfaceStringTest.php | 14 ++- tests/unit/TypeResolverTest.php | 96 ++----------------- 6 files changed, 52 insertions(+), 143 deletions(-) diff --git a/src/PseudoTypes/ClassString.php b/src/PseudoTypes/ClassString.php index 3ddb6cbe..1f5d6582 100644 --- a/src/PseudoTypes/ClassString.php +++ b/src/PseudoTypes/ClassString.php @@ -13,13 +13,10 @@ namespace phpDocumentor\Reflection\PseudoTypes; -use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\String_; -use function implode; - /** * Value Object representing the type 'class-string'. * @@ -27,12 +24,12 @@ */ final class ClassString extends String_ implements PseudoType { - /** @var Fqsen[] */ - private $fqsens; + /** @var Type|null */ + private $genericType; - public function __construct(Fqsen ...$fqsens) + public function __construct(?Type $genericType = null) { - $this->fqsens = $fqsens; + $this->genericType = $genericType; } public function underlyingType(): Type @@ -40,12 +37,9 @@ public function underlyingType(): Type return new String_(); } - /** - * @return Fqsen[] - */ - public function getFqsens(): array + public function getGenericType(): ?Type { - return $this->fqsens; + return $this->genericType; } /** @@ -53,10 +47,10 @@ public function getFqsens(): array */ public function __toString(): string { - if (!$this->fqsens) { + if ($this->genericType === null) { return 'class-string'; } - return 'class-string<' . implode('|', $this->fqsens) . '>'; + return 'class-string<' . (string) $this->genericType . '>'; } } diff --git a/src/PseudoTypes/InterfaceString.php b/src/PseudoTypes/InterfaceString.php index da34e44f..719914cf 100644 --- a/src/PseudoTypes/InterfaceString.php +++ b/src/PseudoTypes/InterfaceString.php @@ -13,13 +13,10 @@ namespace phpDocumentor\Reflection\PseudoTypes; -use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\String_; -use function implode; - /** * Value Object representing the type `interface-string`. * @@ -27,12 +24,12 @@ */ final class InterfaceString extends String_ implements PseudoType { - /** @var Fqsen[] */ - private $fqsens; + /** @var Type|null */ + private $genericType; - public function __construct(Fqsen ...$fqsens) + public function __construct(?Type $genericType = null) { - $this->fqsens = $fqsens; + $this->genericType = $genericType; } public function underlyingType(): Type @@ -40,12 +37,9 @@ public function underlyingType(): Type return new String_(); } - /** - * @return Fqsen[] - */ - public function getFqsens(): array + public function getGenericType(): ?Type { - return $this->fqsens; + return $this->genericType; } /** @@ -53,10 +47,10 @@ public function getFqsens(): array */ public function __toString(): string { - if (!$this->fqsens) { + if ($this->genericType === null) { return 'interface-string'; } - return 'interface-string<' . implode('|', $this->fqsens) . '>'; + return 'interface-string<' . (string) $this->genericType . '>'; } } diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 2faa9ca3..48a2f66f 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -404,10 +404,10 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ return new NonEmptyArray(...$genericTypes); case 'class-string': - return new ClassString(...$this->getFqsensByTypeNode($type->genericTypes[0], $context)); + return new ClassString($this->createType($type->genericTypes[0], $context)); case 'interface-string': - return new InterfaceString(...$this->getFqsensByTypeNode($type->genericTypes[0], $context)); + return new InterfaceString($this->createType($type->genericTypes[0], $context)); case 'list': return new List_( @@ -655,29 +655,6 @@ private function parse(TokenIterator $tokenIterator): TypeNode return $ast; } - /** - * @return Fqsen[] - */ - private function getFqsensByTypeNode(TypeNode $node, Context $context): array - { - $nodes = [$node]; - if ($node instanceof UnionTypeNode) { - $nodes = $node->types; - } - - return array_map( - function (TypeNode $node) use ($context): Fqsen { - $type = $this->createType($node, $context); - if ($type instanceof Object_ === false || $type->getFqsen() === null) { - throw new RuntimeException($type . ' is not a class or interface'); - } - - return $type->getFqsen(); - }, - $nodes - ); - } - /** * @param TypeNode[] $nodes * diff --git a/tests/unit/PseudoTypes/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php index c64f16e5..6f5e370c 100644 --- a/tests/unit/PseudoTypes/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -14,6 +14,8 @@ namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; +use phpDocumentor\Reflection\Types\Compound; +use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; /** @@ -37,9 +39,17 @@ public function provideClassStrings(): array { return [ 'generic class string' => [new ClassString(), 'class-string'], - 'typed class string' => [new ClassString(new Fqsen('\Foo\Bar')), 'class-string<\Foo\Bar>'], + 'typed class string' => [ + new ClassString(new Object_(new Fqsen('\Foo\Bar'))), + 'class-string<\Foo\Bar>', + ], 'more than one class' => [ - new ClassString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), + new ClassString( + new Compound([ + new Object_(new Fqsen('\Foo\Bar')), + new Object_(new Fqsen('\Foo\Barrr')) + ]) + ), 'class-string<\Foo\Bar|\Foo\Barrr>', ], ]; diff --git a/tests/unit/PseudoTypes/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php index 6c62d731..1a26b172 100644 --- a/tests/unit/PseudoTypes/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -14,6 +14,8 @@ namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; +use phpDocumentor\Reflection\Types\Compound; +use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; /** @@ -37,9 +39,17 @@ public function provideInterfaceStrings(): array { return [ 'generic interface string' => [new InterfaceString(), 'interface-string'], - 'typed interface string' => [new InterfaceString(new Fqsen('\Foo\Bar')), 'interface-string<\Foo\Bar>'], + 'typed interface string' => [ + new InterfaceString(new Object_(new Fqsen('\Foo\Bar'))), + 'interface-string<\Foo\Bar>', + ], 'more than one class' => [ - new InterfaceString(new Fqsen('\Foo\Bar'), new Fqsen('\Foo\Barrr')), + new InterfaceString( + new Compound([ + new Object_(new Fqsen('\Foo\Bar')), + new Object_(new Fqsen('\Foo\Barrr')) + ]) + ), 'interface-string<\Foo\Bar|\Foo\Barrr>', ], ]; diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 3ef4419b..6570107e 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -113,56 +113,6 @@ public function testResolvingKeywords(string $keyword, string $expectedClass): v $this->assertInstanceOf($expectedClass, $resolvedType); } - /** - * @uses \phpDocumentor\Reflection\Types\Context - * @uses \phpDocumentor\Reflection\Types\Object_ - * @uses \phpDocumentor\Reflection\Types\String_ - * - * @covers ::__construct - * @covers ::resolve - * @covers ::createType - * @covers :: - * - * @dataProvider provideClassStrings - */ - public function testResolvingClassStrings(string $classString, bool $throwsException): void - { - $fixture = new TypeResolver(); - - if ($throwsException) { - $this->expectException(RuntimeException::class); - } - - $resolvedType = $fixture->resolve($classString, new Context('')); - - $this->assertInstanceOf(ClassString::class, $resolvedType); - } - - /** - * @uses \phpDocumentor\Reflection\Types\Context - * @uses \phpDocumentor\Reflection\Types\Object_ - * @uses \phpDocumentor\Reflection\Types\String_ - * - * @covers ::__construct - * @covers ::resolve - * @covers ::createType - * @covers :: - * - * @dataProvider provideInterfaceStrings - */ - public function testResolvingInterfaceStrings(string $interfaceString, bool $throwsException): void - { - $fixture = new TypeResolver(); - - if ($throwsException) { - $this->expectException(RuntimeException::class); - } - - $resolvedType = $fixture->resolve($interfaceString, new Context('')); - - $this->assertInstanceOf(InterfaceString::class, $resolvedType); - } - /** * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Object_ @@ -831,36 +781,6 @@ public function provideKeywords(): array ]; } - /** - * Returns a list of class string types and whether they throw an exception. - * - * @return (string|bool)[][] - */ - public function provideClassStrings(): array - { - return [ - ['class-string<\phpDocumentor\Reflection>', false], - ['class-string<\phpDocumentor\Reflection\DocBlock>', false], - ['class-string', true], - ['class-string<\Foo&\Bar>', true], - ]; - } - - /** - * Returns a list of interface string types and whether they throw an exception. - * - * @return (string|bool)[][] - */ - public function provideInterfaceStrings(): array - { - return [ - ['interface-string<\phpDocumentor\Reflection>', false], - ['interface-string<\phpDocumentor\Reflection\DocBlock>', false], - ['interface-string', true], - ['interface-string<\Foo&\Bar>', true], - ]; - } - /** * Provides a list of FQSENs to test the resolution patterns with. * @@ -1148,13 +1068,15 @@ public function genericsProvider(): array ], [ 'class-string', - new ClassString(new Fqsen('\\phpDocumentor\\Foo')), + new ClassString(new Object_(new Fqsen('\\phpDocumentor\\Foo'))), ], [ 'class-string', new ClassString( - new Fqsen('\\phpDocumentor\\Foo'), - new Fqsen('\\phpDocumentor\\Bar') + new Compound([ + new Object_(new Fqsen('\\phpDocumentor\\Foo')), + new Object_(new Fqsen('\\phpDocumentor\\Bar')) + ]) ), ], [ @@ -1163,13 +1085,15 @@ public function genericsProvider(): array ], [ 'interface-string', - new InterfaceString(new Fqsen('\\phpDocumentor\\Foo')), + new InterfaceString(new Object_(new Fqsen('\\phpDocumentor\\Foo'))), ], [ 'interface-string', new InterfaceString( - new Fqsen('\\phpDocumentor\\Foo'), - new Fqsen('\\phpDocumentor\\Bar'), + new Compound([ + new Object_(new Fqsen('\\phpDocumentor\\Foo')), + new Object_(new Fqsen('\\phpDocumentor\\Bar')), + ]) ), ], [ From c87931cb832a37a88e1c95b2904974cde9d5e73c 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: Sun, 30 Nov 2025 23:38:46 +0400 Subject: [PATCH 5/5] Fix CS --- tests/unit/PseudoTypes/ClassStringTest.php | 2 +- tests/unit/PseudoTypes/InterfaceStringTest.php | 2 +- tests/unit/TypeResolverTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/PseudoTypes/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php index 6f5e370c..838846d0 100644 --- a/tests/unit/PseudoTypes/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -47,7 +47,7 @@ public function provideClassStrings(): array new ClassString( new Compound([ new Object_(new Fqsen('\Foo\Bar')), - new Object_(new Fqsen('\Foo\Barrr')) + new Object_(new Fqsen('\Foo\Barrr')), ]) ), 'class-string<\Foo\Bar|\Foo\Barrr>', diff --git a/tests/unit/PseudoTypes/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php index 1a26b172..06b18029 100644 --- a/tests/unit/PseudoTypes/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -47,7 +47,7 @@ public function provideInterfaceStrings(): array new InterfaceString( new Compound([ new Object_(new Fqsen('\Foo\Bar')), - new Object_(new Fqsen('\Foo\Barrr')) + new Object_(new Fqsen('\Foo\Barrr')), ]) ), 'interface-string<\Foo\Bar|\Foo\Barrr>', diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 072408d2..1d0b9fd6 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -1057,7 +1057,7 @@ public function genericsProvider(): array new ClassString( new Compound([ new Object_(new Fqsen('\\phpDocumentor\\Foo')), - new Object_(new Fqsen('\\phpDocumentor\\Bar')) + new Object_(new Fqsen('\\phpDocumentor\\Bar')), ]) ), ],