Skip to content

Commit 860c10d

Browse files
committed
Merge branch 'cleanup'
2 parents 8fa588c + cbcd478 commit 860c10d

File tree

17 files changed

+572
-301
lines changed

17 files changed

+572
-301
lines changed

src/Toolkit/Collection/CollectionTrait.php

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Salient\Collection;
44

55
use Salient\Contract\Collection\CollectionInterface;
6-
use Salient\Contract\Core\Arrayable;
76

87
/**
98
* Implements CollectionInterface
@@ -27,9 +26,7 @@ trait CollectionTrait
2726
use ReadableCollectionTrait;
2827

2928
/**
30-
* @param TKey $key
31-
* @param TValue $value
32-
* @return static
29+
* @inheritDoc
3330
*/
3431
public function set($key, $value)
3532
{
@@ -39,8 +36,7 @@ public function set($key, $value)
3936
}
4037

4138
/**
42-
* @param TKey $key
43-
* @return static
39+
* @inheritDoc
4440
*/
4541
public function unset($key)
4642
{
@@ -53,9 +49,7 @@ public function unset($key)
5349
}
5450

5551
/**
56-
* @param TValue|null $last
57-
* @param-out TValue|null $last
58-
* @return static
52+
* @inheritDoc
5953
*/
6054
public function pop(&$last = null)
6155
{
@@ -88,10 +82,9 @@ public function reverse()
8882
}
8983

9084
/**
91-
* @template T of TValue|TKey|array<TKey,TValue>
85+
* @template T of TValue|TKey|array{TKey,TValue}
9286
*
93-
* @param callable(T, T|null $nextValue, T|null $prevValue): bool $callback
94-
* @param CollectionInterface::CALLBACK_USE_* $mode
87+
* @param callable(T, T|null $next, T|null $prev): bool $callback
9588
* @return static A copy of the collection with items that satisfy `$callback`.
9689
*/
9790
public function filter(callable $callback, int $mode = CollectionInterface::CALLBACK_USE_VALUE)
@@ -104,11 +97,7 @@ public function filter(callable $callback, int $mode = CollectionInterface::CALL
10497
$i = 0;
10598

10699
foreach ($this->Items as $nextKey => $nextValue) {
107-
$next = $mode === CollectionInterface::CALLBACK_USE_KEY
108-
? $nextKey
109-
: ($mode === CollectionInterface::CALLBACK_USE_BOTH
110-
? [$nextKey => $nextValue]
111-
: $nextValue);
100+
$next = $this->getCallbackValue($mode, $nextKey, $nextValue);
112101
if ($i++) {
113102
/** @var T $item */
114103
/** @var T $next */
@@ -134,7 +123,6 @@ public function filter(callable $callback, int $mode = CollectionInterface::CALL
134123
}
135124

136125
/**
137-
* @param TKey[] $keys
138126
* @return static A copy of the collection with items that have keys in
139127
* `$keys`.
140128
*/
@@ -147,7 +135,6 @@ public function only(array $keys)
147135
}
148136

149137
/**
150-
* @param array<TKey,true> $index
151138
* @return static A copy of the collection with items that have keys in
152139
* `$index`.
153140
*/
@@ -160,7 +147,6 @@ public function onlyIn(array $index)
160147
}
161148

162149
/**
163-
* @param TKey[] $keys
164150
* @return static A copy of the collection with items that have keys not in
165151
* `$keys`.
166152
*/
@@ -173,7 +159,6 @@ public function except(array $keys)
173159
}
174160

175161
/**
176-
* @param array<TKey,true> $index
177162
* @return static A copy of the collection with items that have keys not in
178163
* `$index`.
179164
*/
@@ -196,9 +181,7 @@ public function slice(int $offset, ?int $length = null)
196181
}
197182

198183
/**
199-
* @param TValue|null $first
200-
* @param-out TValue|null $first
201-
* @return static
184+
* @inheritDoc
202185
*/
203186
public function shift(&$first = null)
204187
{
@@ -212,8 +195,7 @@ public function shift(&$first = null)
212195
}
213196

214197
/**
215-
* @param Arrayable<TKey,TValue>|iterable<TKey,TValue> $items
216-
* @return static
198+
* @inheritDoc
217199
*/
218200
public function merge($items)
219201
{

src/Toolkit/Collection/ImmutableCollectionTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Salient\Collection;
44

55
use Salient\Contract\Collection\CollectionInterface;
6+
use Salient\Contract\Core\Immutable;
67
use Salient\Core\Concern\HasImmutableProperties;
78
use Salient\Core\Concern\ImmutableArrayAccessTrait;
89

@@ -19,6 +20,7 @@
1920
* @template TValue
2021
*
2122
* @phpstan-require-implements CollectionInterface
23+
* @phpstan-require-implements Immutable
2224
*/
2325
trait ImmutableCollectionTrait
2426
{

src/Toolkit/Collection/ImmutableListTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Salient\Collection;
44

55
use Salient\Contract\Collection\ListInterface;
6+
use Salient\Contract\Core\Immutable;
67
use Salient\Core\Concern\HasImmutableProperties;
78
use Salient\Core\Concern\ImmutableArrayAccessTrait;
89

@@ -18,6 +19,7 @@
1819
* @template TValue
1920
*
2021
* @phpstan-require-implements ListInterface
22+
* @phpstan-require-implements Immutable
2123
*/
2224
trait ImmutableListTrait
2325
{

src/Toolkit/Collection/ListTrait.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@ trait ListTrait
3030
}
3131

3232
/**
33-
* @param Arrayable<array-key,TValue>|iterable<array-key,TValue> $items
34-
*/
35-
public function __construct($items = [])
36-
{
37-
$this->Items = $this->getItems($items);
38-
}
39-
40-
/**
41-
* @param TValue $value
42-
* @return static
33+
* @inheritDoc
4334
*/
4435
public function add($value)
4536
{
@@ -49,9 +40,7 @@ public function add($value)
4940
}
5041

5142
/**
52-
* @param int $key
53-
* @param TValue $value
54-
* @return static
43+
* @inheritDoc
5544
*/
5645
public function set($key, $value)
5746
{
@@ -62,8 +51,7 @@ public function set($key, $value)
6251
}
6352

6453
/**
65-
* @param Arrayable<array-key,TValue>|iterable<array-key,TValue> $items
66-
* @return static
54+
* @inheritDoc
6755
*/
6856
public function merge($items)
6957
{
@@ -76,8 +64,7 @@ public function merge($items)
7664
}
7765

7866
/**
79-
* @param TValue ...$item
80-
* @return static
67+
* @inheritDoc
8168
*/
8269
public function push(...$item)
8370
{
@@ -90,8 +77,7 @@ public function push(...$item)
9077
}
9178

9279
/**
93-
* @param TValue ...$item
94-
* @return static
80+
* @inheritDoc
9581
*/
9682
public function unshift(...$item)
9783
{

0 commit comments

Comments
 (0)