11<?php
2+ declare (strict_types=1 );
3+
24namespace ScriptFUSION \Porter \Cache ;
35
46use Psr \Cache \CacheItemInterface ;
911 */
1012class MemoryCache extends \ArrayObject implements CacheItemPoolInterface
1113{
14+ /**
15+ * @param string $key
16+ *
17+ * @return mixed
18+ */
1219 public function getItem ($ key )
1320 {
14- return call_user_func (
15- \Closure::bind (
16- function () use ($ key ) {
17- return new self ($ key , $ this ->hasItem ($ key ) ? $ this [$ key ] : null , $ this ->hasItem ($ key ));
18- },
19- $ this ,
20- CacheItem::class
21- )
22- );
21+ return \Closure::bind (
22+ function () use ($ key ): CacheItem {
23+ return new self ($ key , $ this ->hasItem ($ key ) ? $ this [$ key ] : null , $ this ->hasItem ($ key ));
24+ },
25+ $ this ,
26+ CacheItem::class
27+ )();
2328 }
2429
25- public function getItems (array $ keys = [])
30+ public function getItems (array $ keys = []): iterable
2631 {
2732 foreach ($ keys as $ key ) {
2833 yield $ this ->getItem ($ key );
2934 }
3035 }
3136
32- public function hasItem ($ key )
37+ public function hasItem ($ key ): bool
3338 {
3439 return isset ($ this [$ key ]);
3540 }
3641
37- public function clear ()
42+ public function clear (): void
3843 {
3944 $ this ->exchangeArray ([]);
4045 }
4146
42- public function deleteItem ($ key )
47+ public function deleteItem ($ key ): void
4348 {
4449 unset($ this [$ key ]);
4550 }
4651
47- public function deleteItems (array $ keys )
52+ public function deleteItems (array $ keys ): void
4853 {
4954 foreach ($ keys as $ key ) {
5055 if (!$ this ->hasItem ($ key )) {
@@ -55,17 +60,17 @@ public function deleteItems(array $keys)
5560 }
5661 }
5762
58- public function save (CacheItemInterface $ item )
63+ public function save (CacheItemInterface $ item ): void
5964 {
6065 $ this [$ item ->getKey ()] = $ item ->get ();
6166 }
6267
63- public function saveDeferred (CacheItemInterface $ item )
68+ public function saveDeferred (CacheItemInterface $ item ): void
6469 {
6570 $ this ->save ($ item );
6671 }
6772
68- public function commit ()
73+ public function commit (): bool
6974 {
7075 return true ;
7176 }
0 commit comments