Skip to content

Commit 25b5b40

Browse files
committed
Merge pull request #6 from Ocramius/hotfix/multiple-compound-array-types
Hotfix: multiple compound array types
2 parents f49ac48 + b29c600 commit 25b5b40

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/TypeResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ public function resolve($type, Context $context = null)
104104
return $this->resolveKeyword($type);
105105
case ($this->isCompoundType($type)):
106106
return $this->resolveCompoundType($type, $context);
107-
case $this->isFqsen($type):
108-
return $this->resolveTypedObject($type);
109107
case $this->isTypedArray($type):
110108
return $this->resolveTypedArray($type, $context);
109+
case $this->isFqsen($type):
110+
return $this->resolveTypedObject($type);
111111
case $this->isPartialStructuralElementName($type):
112112
return $this->resolveTypedObject($type, $context);
113113
// @codeCoverageIgnoreStart

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)