Skip to content

Commit 6325be7

Browse files
committed
Merge branch 'review'
2 parents 7526e85 + 67913dc commit 6325be7

File tree

89 files changed

+1287
-1505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1287
-1505
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"psr/simple-cache-implementation": "^1 || ^2"
7474
},
7575
"suggest": {
76+
"ext-sqlite3": "Required by CacheStore and SyncStore",
7677
"adodb/adodb-php": "Required for access to databases",
7778
"analog/analog": "Allows Analog handlers to be used as console message targets",
7879
"firebase/php-jwt": "Required for validation of OAuth 2.0 access tokens",

phpstan-baseline-7.4.neon

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline-8.3.neon

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/delete-covers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$check = !in_array('--force', $args);
2121

2222
$files = File::find()
23+
->files()
2324
->in(dirname(__DIR__) . '/tests/unit')
2425
->include('/Test\.php$/')
2526
->toArray();

scripts/generate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
$builders = [
9696
CliOption::class => [CliOptionBuilder::class, '--forward=load', '--no-declare=valueCallback', '--desc', '', '--api'],
97-
Curler::class => [CurlerBuilder::class, '--forward=head,get,post,put,patch,delete,getP,postP,putP,patchP,deleteP,postR,putR,patchR,deleteR', '--desc', '', '--api'],
97+
Curler::class => [CurlerBuilder::class, '--constructor', 'create', '--forward=head,get,post,put,patch,delete,getP,postP,putP,patchP,deleteP,postR,putR,patchR,deleteR,sendRequest', '--desc', '', '--api'],
9898
DbSyncDefinition::class => [DbSyncDefinitionBuilder::class, '--no-declare=overrides', '--desc', ''],
9999
HttpSyncDefinition::class => [HttpSyncDefinitionBuilder::class, '--no-declare=callback,curlerCallback,overrides', '--desc', ''],
100100
SyncError::class => [SyncErrorBuilder::class, '--desc', ''],
@@ -256,6 +256,7 @@ function generated($commandOrFile): void
256256

257257
foreach (
258258
File::find()
259+
->files()
259260
->in($dir)
260261
->include('%/phpstan-baseline.*\.neon$%')
261262
->doNotRecurse() as $file

src/Toolkit/Cache/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
},
1616
"require": {
1717
"php": ">=7.4",
18+
"ext-sqlite3": "*",
1819
"salient/contracts": "self.version",
19-
"salient/core": "self.version"
20+
"salient/core": "self.version",
21+
"salient/utils": "self.version"
2022
},
2123
"provide": {
2224
"psr/simple-cache-implementation": "^1 || ^2"

src/Toolkit/Collection/Collection.php

Lines changed: 4 additions & 2 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 IteratorAggregate;
67

78
/**
89
* @api
@@ -11,9 +12,10 @@
1112
* @template TValue
1213
*
1314
* @implements CollectionInterface<TKey,TValue>
15+
* @implements IteratorAggregate<TKey,TValue>
1416
*/
15-
class Collection implements CollectionInterface
17+
class Collection implements CollectionInterface, IteratorAggregate
1618
{
17-
/** @use CollectionTrait<TKey,TValue> */
19+
/** @use CollectionTrait<TKey,TValue,static<TKey|int,TValue>> */
1820
use CollectionTrait;
1921
}

src/Toolkit/Collection/CollectionTrait.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* @template TKey of array-key
1111
* @template TValue
12+
* @template TKeyless
1213
*
1314
* @phpstan-require-implements CollectionInterface
1415
*/
@@ -47,6 +48,7 @@ public function add($value)
4748
{
4849
$items = $this->Items;
4950
$items[] = $value;
51+
/** @var TKeyless */
5052
return $this->replaceItems($items, true);
5153
}
5254

@@ -95,7 +97,6 @@ public function reverse()
9597
*/
9698
public function map(callable $callback, int $mode = CollectionInterface::CALLBACK_USE_VALUE)
9799
{
98-
$items = [];
99100
$prev = null;
100101
$item = null;
101102
$key = null;
@@ -116,28 +117,25 @@ public function map(callable $callback, int $mode = CollectionInterface::CALLBAC
116117
}
117118

118119
// @phpstan-ignore argument.type, return.type
119-
return $this->maybeReplaceItems($items, true);
120+
return $this->maybeReplaceItems($items ?? [], true);
120121
}
121122

122123
/**
123124
* @inheritDoc
124125
*/
125126
public function filter(callable $callback, int $mode = CollectionInterface::CALLBACK_USE_VALUE)
126127
{
127-
$items = [];
128128
$prev = null;
129129
$item = null;
130130
$key = null;
131131
$value = null;
132132

133133
foreach ($this->Items as $nextKey => $nextValue) {
134134
$next = $this->getCallbackValue($mode, $nextKey, $nextValue);
135-
if ($item !== null) {
136-
if ($callback($item, $next, $prev)) {
137-
/** @var TKey $key */
138-
/** @var TValue $value */
139-
$items[$key] = $value;
140-
}
135+
if ($item !== null && $callback($item, $next, $prev)) {
136+
/** @var TKey $key */
137+
/** @var TValue $value */
138+
$items[$key] = $value;
141139
}
142140
$prev = $item;
143141
$item = $next;
@@ -150,7 +148,7 @@ public function filter(callable $callback, int $mode = CollectionInterface::CALL
150148
$items[$key] = $value;
151149
}
152150

153-
return $this->maybeReplaceItems($items);
151+
return $this->maybeReplaceItems($items ?? []);
154152
}
155153

156154
/**
@@ -204,10 +202,12 @@ public function slice(int $offset, ?int $length = null)
204202
public function push(...$items)
205203
{
206204
if (!$items) {
205+
/** @var TKeyless */
207206
return $this;
208207
}
209208
$_items = $this->Items;
210209
array_push($_items, ...$items);
210+
/** @var TKeyless */
211211
return $this->replaceItems($_items, true);
212212
}
213213

@@ -246,15 +246,15 @@ public function shift(&$first = null)
246246
public function unshift(...$items)
247247
{
248248
if (!$items) {
249+
/** @var TKeyless */
249250
return $this;
250251
}
251252
$_items = $this->Items;
252253
array_unshift($_items, ...$items);
254+
/** @var TKeyless */
253255
return $this->replaceItems($_items, true);
254256
}
255257

256-
// Partial implementation of `ArrayAccess`:
257-
258258
/**
259259
* @param TKey|null $offset
260260
* @param TValue $value
@@ -281,8 +281,6 @@ public function offsetUnset($offset): void
281281
$this->maybeReplaceItems($items, false, false);
282282
}
283283

284-
// --
285-
286284
/**
287285
* @param array<TKey,TValue> $items
288286
* @return static

src/Toolkit/Collection/ListCollection.php

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

55
use Salient\Contract\Collection\CollectionInterface;
6+
use IteratorAggregate;
67

78
/**
89
* @api
910
*
1011
* @template TValue
1112
*
1213
* @implements CollectionInterface<int,TValue>
14+
* @implements IteratorAggregate<int,TValue>
1315
*/
14-
class ListCollection implements CollectionInterface
16+
class ListCollection implements CollectionInterface, IteratorAggregate
1517
{
16-
/** @use ListCollectionTrait<int,TValue> */
18+
/** @use ListCollectionTrait<int,TValue,static<TValue>> */
1719
use ListCollectionTrait;
1820
}

src/Toolkit/Collection/ListCollectionTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
*
1111
* @template TKey of int
1212
* @template TValue
13+
* @template TKeyless
1314
*
1415
* @phpstan-require-implements CollectionInterface
1516
*/
1617
trait ListCollectionTrait
1718
{
18-
/** @use CollectionTrait<int,TValue> */
19+
/** @use CollectionTrait<int,TValue,TKeyless> */
1920
use CollectionTrait {
2021
getItems as private doGetItems;
2122
replaceItems as private doReplaceItems;
@@ -48,8 +49,6 @@ public function shift(&$first = null)
4849
return $this->replaceItems($items, true);
4950
}
5051

51-
// --
52-
5352
/**
5453
* @param Arrayable<array-key,TValue>|iterable<array-key,TValue> $items
5554
* @return iterable<TValue>

0 commit comments

Comments
 (0)