Skip to content

Commit 3ccfe42

Browse files
committed
Add LooselyTypedCollection class
1 parent df0a3d9 commit 3ccfe42

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Lkrms\Concept;
4+
5+
use Lkrms\Concern\TCollection;
6+
use Lkrms\Contract\ICollection;
7+
use Lkrms\Contract\IImmutable;
8+
9+
/**
10+
* Base class for collections of objects of an unenforced type
11+
*
12+
* Extend {@see TypedCollection} instead if type safety concerns outweigh
13+
* performance.
14+
*
15+
* @template TKey of array-key
16+
* @template TValue of object
17+
*
18+
* @implements ICollection<TKey,TValue>
19+
*/
20+
abstract class LooselyTypedCollection implements ICollection, IImmutable
21+
{
22+
/**
23+
* @use TCollection<TKey,TValue>
24+
*/
25+
use TCollection;
26+
}

src/Concept/TypedCollection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
use LogicException;
99

1010
/**
11-
* Base class for collections of objects of a given type
11+
* Base class for collections of objects of a strictly enforced type
12+
*
13+
* Extend {@see LooselyTypedCollection} instead if performance concerns outweigh
14+
* type safety.
1215
*
1316
* @template TKey of array-key
1417
* @template TValue of object

0 commit comments

Comments
 (0)