Skip to content

Commit fad4527

Browse files
authored
Merge pull request #194 from antoinelame/1.x
Add getter to ArrayShape
2 parents 8430ca5 + 029d5bf commit fad4527

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/PseudoTypes/ArrayShape.php

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public function __construct(ArrayShapeItem ...$items)
3232
$this->items = $items;
3333
}
3434

35+
/**
36+
* @return ArrayShapeItem[]
37+
*/
38+
public function getItems(): array
39+
{
40+
return $this->items;
41+
}
42+
3543
public function underlyingType(): Type
3644
{
3745
return new Array_(new Mixed_(), new ArrayKey());
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace phpDocumentor\Reflection\PseudoTypes;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
class ArrayShapeTest extends TestCase
8+
{
9+
/**
10+
* @covers ::getItems
11+
*/
12+
public function testExposeItems(): void
13+
{
14+
$item1 = new ArrayShapeItem('foo', new True_(), false);
15+
$item2 = new ArrayShapeItem('bar', new False_(), true);
16+
17+
$arrayShape = new ArrayShape($item1, $item2);
18+
19+
$this->assertSame([$item1, $item2], $arrayShape->getItems());
20+
}
21+
}

0 commit comments

Comments
 (0)