Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit855b47f

Browse files
feature#41290 [Cache] Implement psr/cache 3 (derrabus)
This PR was merged into the 6.0 branch.Discussion----------[Cache] Implement psr/cache 3| Q | A| ------------- | ---| Branch? | 6.0| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | N/A| License | MIT| Doc PR | N/AThis PR adds the necessary return types to support version 3 of the `psr/cache` interfaces. I did not add parameter types in order to maintain v1 compatibility, but we could as well decide to drop v1 if we want.Commits-------71d76c4 [Cache] Implement psr/cache 3
2 parentsed78403 +71d76c4 commit855b47f

15 files changed

+96
-218
lines changed

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"provide": {
1919
"php-http/async-client-implementation":"*",
2020
"php-http/client-implementation":"*",
21-
"psr/cache-implementation":"1.0|2.0",
21+
"psr/cache-implementation":"1.0|2.0|3.0",
2222
"psr/container-implementation":"1.0",
2323
"psr/event-dispatcher-implementation":"1.0",
2424
"psr/http-client-implementation":"1.0",
@@ -38,7 +38,7 @@
3838
"doctrine/event-manager":"~1.0",
3939
"doctrine/persistence":"^2",
4040
"twig/twig":"^2.13|^3.0.4",
41-
"psr/cache":"^1.0|^2.0",
41+
"psr/cache":"^1.0|^2.0|^3.0",
4242
"psr/container":"^1.0",
4343
"psr/event-dispatcher":"^1.0",
4444
"psr/link":"^1.1",

‎src/Symfony/Component/Cache/Adapter/AbstractAdapter.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ public static function createConnection(string $dsn, array $options = [])
141141

142142
/**
143143
* {@inheritdoc}
144-
*
145-
* @return bool
146144
*/
147-
publicfunctioncommit()
145+
publicfunctioncommit():bool
148146
{
149147
$ok =true;
150148
$byLifetime = (self::$mergeByLifetime)($this->deferred,$this->namespace,$expiredIds, \Closure::fromCallable([$this,'getId']),$this->defaultLifetime);

‎src/Symfony/Component/Cache/Adapter/AdapterInterface.php‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,18 @@ interface AdapterInterface extends CacheItemPoolInterface
2626
{
2727
/**
2828
* {@inheritdoc}
29-
*
30-
* @return CacheItem
3129
*/
32-
publicfunctiongetItem($key);
30+
publicfunctiongetItem($key):CacheItem;
3331

3432
/**
3533
* {@inheritdoc}
3634
*
37-
* @return\Traversable|CacheItem[]
35+
* @returniterable<CacheItem>
3836
*/
39-
publicfunctiongetItems(array$keys = []);
37+
publicfunctiongetItems(array$keys = []):iterable;
4038

4139
/**
4240
* {@inheritdoc}
43-
*
44-
* @return bool
4541
*/
46-
publicfunctionclear(string$prefix ='');
42+
publicfunctionclear(string$prefix =''):bool;
4743
}

‎src/Symfony/Component/Cache/Adapter/ArrayAdapter.php‎

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ public function delete(string $key): bool
9797

9898
/**
9999
* {@inheritdoc}
100-
*
101-
* @return bool
102100
*/
103-
publicfunctionhasItem($key)
101+
publicfunctionhasItem($key):bool
104102
{
105103
if (\is_string($key) &&isset($this->expiries[$key]) &&$this->expiries[$key] >microtime(true)) {
106104
if ($this->maxItems) {
@@ -120,7 +118,7 @@ public function hasItem($key)
120118
/**
121119
* {@inheritdoc}
122120
*/
123-
publicfunctiongetItem($key)
121+
publicfunctiongetItem($key):CacheItem
124122
{
125123
if (!$isHit =$this->hasItem($key)) {
126124
$value =null;
@@ -139,7 +137,7 @@ public function getItem($key)
139137
/**
140138
* {@inheritdoc}
141139
*/
142-
publicfunctiongetItems(array$keys = [])
140+
publicfunctiongetItems(array$keys = []):iterable
143141
{
144142
\assert(self::validateKeys($keys));
145143

@@ -148,10 +146,8 @@ public function getItems(array $keys = [])
148146

149147
/**
150148
* {@inheritdoc}
151-
*
152-
* @return bool
153149
*/
154-
publicfunctiondeleteItem($key)
150+
publicfunctiondeleteItem($key):bool
155151
{
156152
\assert('' !== CacheItem::validateKey($key));
157153
unset($this->values[$key],$this->expiries[$key]);
@@ -161,10 +157,8 @@ public function deleteItem($key)
161157

162158
/**
163159
* {@inheritdoc}
164-
*
165-
* @return bool
166160
*/
167-
publicfunctiondeleteItems(array$keys)
161+
publicfunctiondeleteItems(array$keys):bool
168162
{
169163
foreach ($keysas$key) {
170164
$this->deleteItem($key);
@@ -175,10 +169,8 @@ public function deleteItems(array $keys)
175169

176170
/**
177171
* {@inheritdoc}
178-
*
179-
* @return bool
180172
*/
181-
publicfunctionsave(CacheItemInterface$item)
173+
publicfunctionsave(CacheItemInterface$item):bool
182174
{
183175
if (!$iteminstanceof CacheItem) {
184176
returnfalse;
@@ -230,30 +222,24 @@ public function save(CacheItemInterface $item)
230222

231223
/**
232224
* {@inheritdoc}
233-
*
234-
* @return bool
235225
*/
236-
publicfunctionsaveDeferred(CacheItemInterface$item)
226+
publicfunctionsaveDeferred(CacheItemInterface$item):bool
237227
{
238228
return$this->save($item);
239229
}
240230

241231
/**
242232
* {@inheritdoc}
243-
*
244-
* @return bool
245233
*/
246-
publicfunctioncommit()
234+
publicfunctioncommit():bool
247235
{
248236
returntrue;
249237
}
250238

251239
/**
252240
* {@inheritdoc}
253-
*
254-
* @return bool
255241
*/
256-
publicfunctionclear(string$prefix ='')
242+
publicfunctionclear(string$prefix =''):bool
257243
{
258244
if ('' !==$prefix) {
259245
$now =microtime(true);
@@ -276,10 +262,8 @@ public function clear(string $prefix = '')
276262

277263
/**
278264
* Returns all cached values, with cache miss as null.
279-
*
280-
* @return array
281265
*/
282-
publicfunctiongetValues()
266+
publicfunctiongetValues():array
283267
{
284268
if (!$this->storeSerialized) {
285269
return$this->values;
@@ -306,7 +290,7 @@ public function reset()
306290
$this->clear();
307291
}
308292

309-
privatefunctiongenerateItems(array$keys,$now,$f)
293+
privatefunctiongenerateItems(array$keys,$now,$f):\Generator
310294
{
311295
foreach ($keysas$i =>$key) {
312296
if (!$isHit =isset($this->expiries[$key]) && ($this->expiries[$key] >$now || !$this->deleteItem($key))) {

‎src/Symfony/Component/Cache/Adapter/ChainAdapter.php‎

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
120120
/**
121121
* {@inheritdoc}
122122
*/
123-
publicfunctiongetItem($key)
123+
publicfunctiongetItem($key):CacheItem
124124
{
125125
$syncItem =self::$syncItem;
126126
$misses = [];
@@ -145,12 +145,12 @@ public function getItem($key)
145145
/**
146146
* {@inheritdoc}
147147
*/
148-
publicfunctiongetItems(array$keys = [])
148+
publicfunctiongetItems(array$keys = []):iterable
149149
{
150150
return$this->generateItems($this->adapters[0]->getItems($keys),0);
151151
}
152152

153-
privatefunctiongenerateItems(iterable$items,int$adapterIndex)
153+
privatefunctiongenerateItems(iterable$items,int$adapterIndex):\Generator
154154
{
155155
$missing = [];
156156
$misses = [];
@@ -183,10 +183,8 @@ private function generateItems(iterable $items, int $adapterIndex)
183183

184184
/**
185185
* {@inheritdoc}
186-
*
187-
* @return bool
188186
*/
189-
publicfunctionhasItem($key)
187+
publicfunctionhasItem($key):bool
190188
{
191189
foreach ($this->adaptersas$adapter) {
192190
if ($adapter->hasItem($key)) {
@@ -199,10 +197,8 @@ public function hasItem($key)
199197

200198
/**
201199
* {@inheritdoc}
202-
*
203-
* @return bool
204200
*/
205-
publicfunctionclear(string$prefix ='')
201+
publicfunctionclear(string$prefix =''):bool
206202
{
207203
$cleared =true;
208204
$i =$this->adapterCount;
@@ -220,10 +216,8 @@ public function clear(string $prefix = '')
220216

221217
/**
222218
* {@inheritdoc}
223-
*
224-
* @return bool
225219
*/
226-
publicfunctiondeleteItem($key)
220+
publicfunctiondeleteItem($key):bool
227221
{
228222
$deleted =true;
229223
$i =$this->adapterCount;
@@ -237,10 +231,8 @@ public function deleteItem($key)
237231

238232
/**
239233
* {@inheritdoc}
240-
*
241-
* @return bool
242234
*/
243-
publicfunctiondeleteItems(array$keys)
235+
publicfunctiondeleteItems(array$keys):bool
244236
{
245237
$deleted =true;
246238
$i =$this->adapterCount;
@@ -254,10 +246,8 @@ public function deleteItems(array $keys)
254246

255247
/**
256248
* {@inheritdoc}
257-
*
258-
* @return bool
259249
*/
260-
publicfunctionsave(CacheItemInterface$item)
250+
publicfunctionsave(CacheItemInterface$item):bool
261251
{
262252
$saved =true;
263253
$i =$this->adapterCount;
@@ -271,10 +261,8 @@ public function save(CacheItemInterface $item)
271261

272262
/**
273263
* {@inheritdoc}
274-
*
275-
* @return bool
276264
*/
277-
publicfunctionsaveDeferred(CacheItemInterface$item)
265+
publicfunctionsaveDeferred(CacheItemInterface$item):bool
278266
{
279267
$saved =true;
280268
$i =$this->adapterCount;
@@ -288,10 +276,8 @@ public function saveDeferred(CacheItemInterface $item)
288276

289277
/**
290278
* {@inheritdoc}
291-
*
292-
* @return bool
293279
*/
294-
publicfunctioncommit()
280+
publicfunctioncommit():bool
295281
{
296282
$committed =true;
297283
$i =$this->adapterCount;

‎src/Symfony/Component/Cache/Adapter/NullAdapter.php‎

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,85 +50,71 @@ public function get(string $key, callable $callback, float $beta = null, array &
5050
/**
5151
* {@inheritdoc}
5252
*/
53-
publicfunctiongetItem($key)
53+
publicfunctiongetItem($key):CacheItem
5454
{
5555
return (self::$createCacheItem)($key);
5656
}
5757

5858
/**
5959
* {@inheritdoc}
6060
*/
61-
publicfunctiongetItems(array$keys = [])
61+
publicfunctiongetItems(array$keys = []):iterable
6262
{
6363
return$this->generateItems($keys);
6464
}
6565

6666
/**
6767
* {@inheritdoc}
68-
*
69-
* @return bool
7068
*/
71-
publicfunctionhasItem($key)
69+
publicfunctionhasItem($key):bool
7270
{
7371
returnfalse;
7472
}
7573

7674
/**
7775
* {@inheritdoc}
78-
*
79-
* @return bool
8076
*/
81-
publicfunctionclear(string$prefix ='')
77+
publicfunctionclear(string$prefix =''):bool
8278
{
8379
returntrue;
8480
}
8581

8682
/**
8783
* {@inheritdoc}
88-
*
89-
* @return bool
9084
*/
91-
publicfunctiondeleteItem($key)
85+
publicfunctiondeleteItem($key):bool
9286
{
9387
returntrue;
9488
}
9589

9690
/**
9791
* {@inheritdoc}
98-
*
99-
* @return bool
10092
*/
101-
publicfunctiondeleteItems(array$keys)
93+
publicfunctiondeleteItems(array$keys):bool
10294
{
10395
returntrue;
10496
}
10597

10698
/**
10799
* {@inheritdoc}
108-
*
109-
* @return bool
110100
*/
111-
publicfunctionsave(CacheItemInterface$item)
101+
publicfunctionsave(CacheItemInterface$item):bool
112102
{
113103
returntrue;
114104
}
115105

116106
/**
117107
* {@inheritdoc}
118-
*
119-
* @return bool
120108
*/
121-
publicfunctionsaveDeferred(CacheItemInterface$item)
109+
publicfunctionsaveDeferred(CacheItemInterface$item):bool
122110
{
123111
returntrue;
124112
}
125113

126114
/**
127115
* {@inheritdoc}
128-
*
129-
* @return bool
130116
*/
131-
publicfunctioncommit()
117+
publicfunctioncommit():bool
132118
{
133119
returntrue;
134120
}
@@ -141,7 +127,7 @@ public function delete(string $key): bool
141127
return$this->deleteItem($key);
142128
}
143129

144-
privatefunctiongenerateItems(array$keys)
130+
privatefunctiongenerateItems(array$keys):\Generator
145131
{
146132
$f =self::$createCacheItem;
147133

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp