Skip to content

Commit b90fdb5

Browse files
committed
Test case: compound typed arrays crash the type resolver
1 parent f49ac48 commit b90fdb5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/unit/TypeResolverTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,40 @@ public function testResolvingCompoundTypes()
204204
$this->assertInstanceOf('phpDocumentor\Reflection\Fqsen', $secondType->getFqsen());
205205
}
206206

207+
/**
208+
* @covers ::__construct
209+
* @covers ::resolve
210+
* @covers ::<private>
211+
*
212+
* @uses phpDocumentor\Reflection\Types\Context
213+
* @uses phpDocumentor\Reflection\Types\Compound
214+
* @uses phpDocumentor\Reflection\Types\Array_
215+
* @uses phpDocumentor\Reflection\Types\Object_
216+
* @uses phpDocumentor\Reflection\Fqsen
217+
* @uses phpDocumentor\Reflection\FqsenResolver
218+
*/
219+
public function testResolvingCompoundTypedArrayTypes()
220+
{
221+
$fixture = new TypeResolver();
222+
223+
/** @var Compound $resolvedType */
224+
$resolvedType = $fixture->resolve('\stdClass[]|Reflection\DocBlock[]', new Context('phpDocumentor'));
225+
226+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType);
227+
$this->assertSame('\stdClass[]|\phpDocumentor\Reflection\DocBlock[]', (string)$resolvedType);
228+
229+
/** @var Array_ $secondType */
230+
$firstType = $resolvedType->get(0);
231+
232+
/** @var Array_ $secondType */
233+
$secondType = $resolvedType->get(1);
234+
235+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $firstType);
236+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $secondType);
237+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $firstType->getValueType());
238+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $secondType->getValueType());
239+
}
240+
207241
/**
208242
* This test asserts that the parameter order is correct.
209243
*

0 commit comments

Comments
 (0)