@@ -68,20 +68,17 @@ final public function getNamespace(): string
68
68
69
69
/**
70
70
* Returns new nested cache object.
71
- * @return static
72
71
*/
73
- public function derive (string $ namespace )
72
+ public function derive (string $ namespace ): static
74
73
{
75
74
return new static ($ this ->storage , $ this ->namespace . $ namespace );
76
75
}
77
76
78
77
79
78
/**
80
79
* Reads the specified item from the cache or generate it.
81
- * @param mixed $key
82
- * @return mixed
83
80
*/
84
- public function load ($ key , ?callable $ generator = null )
81
+ public function load (mixed $ key , ?callable $ generator = null ): mixed
85
82
{
86
83
$ storageKey = $ this ->generateKey ($ key );
87
84
$ data = $ this ->storage ->read ($ storageKey );
@@ -158,12 +155,10 @@ public function bulkLoad(array $keys, ?callable $generator = null): array
158
155
* - Cache::ITEMS => (array|string) cache items
159
156
* - Cache::CONSTS => (array|string) cache items
160
157
*
161
- * @param mixed $key
162
- * @param mixed $data
163
158
* @return mixed value itself
164
159
* @throws Nette\InvalidArgumentException
165
160
*/
166
- public function save ($ key , $ data , ?array $ dependencies = null )
161
+ public function save (mixed $ key , mixed $ data , ?array $ dependencies = null ): mixed
167
162
{
168
163
$ key = $ this ->generateKey ($ key );
169
164
@@ -179,6 +174,7 @@ public function save($key, $data, ?array $dependencies = null)
179
174
180
175
if ($ data === null ) {
181
176
$ this ->storage ->remove ($ key );
177
+ return null ;
182
178
} else {
183
179
$ dependencies = $ this ->completeDependencies ($ dependencies );
184
180
if (isset ($ dependencies [self ::EXPIRATION ]) && $ dependencies [self ::EXPIRATION ] <= 0 ) {
@@ -242,9 +238,8 @@ private function completeDependencies(?array $dp): array
242
238
243
239
/**
244
240
* Removes item from the cache.
245
- * @param mixed $key
246
241
*/
247
- public function remove ($ key ): void
242
+ public function remove (mixed $ key ): void
248
243
{
249
244
$ this ->save ($ key , null );
250
245
}
@@ -270,9 +265,8 @@ public function clean(?array $conditions = null): void
270
265
271
266
/**
272
267
* Caches results of function/method calls.
273
- * @return mixed
274
268
*/
275
- public function call (callable $ function )
269
+ public function call (callable $ function ): mixed
276
270
{
277
271
$ key = func_get_args ();
278
272
if (is_array ($ function ) && is_object ($ function [0 ])) {
@@ -304,9 +298,8 @@ public function wrap(callable $function, ?array $dependencies = null): \Closure
304
298
305
299
/**
306
300
* Starts the output cache.
307
- * @param mixed $key
308
301
*/
309
- public function capture ($ key ): ?OutputHelper
302
+ public function capture (mixed $ key ): ?OutputHelper
310
303
{
311
304
$ data = $ this ->load ($ key );
312
305
if ($ data === null ) {
0 commit comments