Skip to content

Commit 7b4088f

Browse files
committed
Changed RecordCollection encapsulation type from array -> mixed.
1 parent feb406a commit 7b4088f

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

src/Collection/PorterRecords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct(RecordCollection $records, private readonly Import $
1111
{
1212
parent::__construct($records, $records);
1313

14-
// Force generators to run to first suspension point.
14+
// Force generators to run to the first suspension point.
1515
$records->valid();
1616
}
1717

src/Collection/RecordCollection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public function __construct(private readonly \Iterator $records, private readonl
1212
{
1313
}
1414

15-
// TODO: Consider throwing our own exception type for clarity, instead of relying on PHP's TypeError.
16-
public function current(): array
15+
public function current(): mixed
1716
{
1817
return $this->records->current();
1918
}

src/Porter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public function import(Import $import): PorterRecords|CountablePorterRecords
6262
*
6363
* @param Import $import Import specification.
6464
*
65-
* @return array|null Record.
65+
* @return mixed Record.
6666
*
6767
* @throws IncompatibleResourceException Resource does not implement required interface.
6868
* @throws ImportException More than one record was imported.
6969
*/
70-
public function importOne(Import $import): ?array
70+
public function importOne(Import $import): mixed
7171
{
7272
if (!$import->getResource() instanceof SingleRecordResource) {
7373
throw IncompatibleResourceException::createMustImplementInterface();

test/Unit/Collection/RecordCollectionTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,16 @@ public function testFindFirstCollection(): void
4040
}
4141

4242
/**
43-
* Tests that when a RecordCollection yields a non-array datum, an exception is thrown.
43+
* Tests that when a RecordCollection yields a non-array datum, the datum is returned as-is.
4444
*/
4545
public function testNonArrayYield(): void
4646
{
4747
/** @var RecordCollection $collection */
4848
$collection = \Mockery::mock(
4949
RecordCollection::class,
50-
[new \ArrayIterator(['foo'])]
50+
[new \ArrayIterator([$datum = 'foo'])]
5151
)->makePartial();
5252

53-
$this->expectException(\TypeError::class);
54-
$this->expectExceptionMessageMatches('[must be of( the)? type array]');
55-
$collection->current();
53+
self::assertSame($datum, $collection->current());
5654
}
5755
}

0 commit comments

Comments
 (0)