Skip to content

Commit

Permalink
Merge pull request #194 from antoinelame/1.x
Browse files Browse the repository at this point in the history
Add getter to ArrayShape
  • Loading branch information
jaapio committed Jan 11, 2024
2 parents 8430ca5 + 029d5bf commit fad4527
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/PseudoTypes/ArrayShape.php
Expand Up @@ -32,6 +32,14 @@ public function __construct(ArrayShapeItem ...$items)
$this->items = $items;
}

/**
* @return ArrayShapeItem[]
*/
public function getItems(): array
{
return $this->items;
}

public function underlyingType(): Type
{
return new Array_(new Mixed_(), new ArrayKey());
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/PseudoTypes/ArrayShapeTest.php
@@ -0,0 +1,21 @@
<?php

namespace phpDocumentor\Reflection\PseudoTypes;

use PHPUnit\Framework\TestCase;

class ArrayShapeTest extends TestCase
{
/**
* @covers ::getItems
*/
public function testExposeItems(): void
{
$item1 = new ArrayShapeItem('foo', new True_(), false);
$item2 = new ArrayShapeItem('bar', new False_(), true);

$arrayShape = new ArrayShape($item1, $item2);

$this->assertSame([$item1, $item2], $arrayShape->getItems());
}
}

0 comments on commit fad4527

Please sign in to comment.