@@ -83,10 +83,9 @@ public function __construct($dir, IJournal $journal = NULL)
83
83
84
84
/**
85
85
* Read from cache.
86
- * @param string
87
86
* @return mixed
88
87
*/
89
- public function read ($ key )
88
+ public function read (string $ key )
90
89
{
91
90
$ meta = $ this ->readMetaAndLock ($ this ->getCacheFile ($ key ), LOCK_SH );
92
91
if ($ meta && $ this ->verify ($ meta )) {
@@ -100,10 +99,8 @@ public function read($key)
100
99
101
100
/**
102
101
* Verifies dependencies.
103
- * @param array
104
- * @return bool
105
102
*/
106
- private function verify ($ meta )
103
+ private function verify (array $ meta ): bool
107
104
{
108
105
do {
109
106
if (!empty ($ meta [self ::META_DELTA ])) {
@@ -140,10 +137,9 @@ private function verify($meta)
140
137
141
138
/**
142
139
* Prevents item reading and writing. Lock is released by write() or remove().
143
- * @param string
144
140
* @return void
145
141
*/
146
- public function lock ($ key )
142
+ public function lock (string $ key )
147
143
{
148
144
$ cacheFile = $ this ->getCacheFile ($ key );
149
145
if ($ this ->useDirs && !is_dir ($ dir = dirname ($ cacheFile ))) {
@@ -159,11 +155,9 @@ public function lock($key)
159
155
160
156
/**
161
157
* Writes item into the cache.
162
- * @param string
163
- * @param mixed
164
158
* @return void
165
159
*/
166
- public function write ($ key , $ data , array $ dp )
160
+ public function write (string $ key , $ data , array $ dp )
167
161
{
168
162
$ meta = [
169
163
self ::META_TIME => microtime (),
@@ -244,10 +238,9 @@ public function write($key, $data, array $dp)
244
238
245
239
/**
246
240
* Removes item from the cache.
247
- * @param string
248
241
* @return void
249
242
*/
250
- public function remove ($ key )
243
+ public function remove (string $ key )
251
244
{
252
245
unset($ this ->locks [$ key ]);
253
246
$ this ->delete ($ this ->getCacheFile ($ key ));
@@ -256,7 +249,6 @@ public function remove($key)
256
249
257
250
/**
258
251
* Removes items from the cache by conditions & garbage collector.
259
- * @param array conditions
260
252
* @return void
261
253
*/
262
254
public function clean (array $ conditions )
@@ -315,7 +307,7 @@ public function clean(array $conditions)
315
307
* @param int lock mode
316
308
* @return array|NULL
317
309
*/
318
- protected function readMetaAndLock ($ file , $ lock )
310
+ protected function readMetaAndLock (string $ file , int $ lock )
319
311
{
320
312
$ handle = @fopen ($ file , 'r+b ' ); // @ - file may not exist
321
313
if (!$ handle ) {
@@ -342,10 +334,9 @@ protected function readMetaAndLock($file, $lock)
342
334
343
335
/**
344
336
* Reads cache data from disk and closes cache file handle.
345
- * @param array
346
337
* @return mixed
347
338
*/
348
- protected function readData ($ meta )
339
+ protected function readData (array $ meta )
349
340
{
350
341
$ data = stream_get_contents ($ meta [self ::HANDLE ]);
351
342
flock ($ meta [self ::HANDLE ], LOCK_UN );
@@ -361,10 +352,8 @@ protected function readData($meta)
361
352
362
353
/**
363
354
* Returns file name.
364
- * @param string
365
- * @return string
366
355
*/
367
- protected function getCacheFile ($ key )
356
+ protected function getCacheFile (string $ key ): string
368
357
{
369
358
$ file = urlencode ($ key );
370
359
if ($ this ->useDirs && $ a = strrpos ($ file , '%00 ' )) { // %00 = urlencode(Nette\Caching\Cache::NAMESPACE_SEPARATOR)
@@ -376,11 +365,10 @@ protected function getCacheFile($key)
376
365
377
366
/**
378
367
* Deletes and closes file.
379
- * @param string
380
- * @param resource
368
+ * @param resource $handle
381
369
* @return void
382
370
*/
383
- private static function delete ($ file , $ handle = NULL )
371
+ private static function delete (string $ file , $ handle = NULL )
384
372
{
385
373
if (@unlink ($ file )) { // @ - file may not already exist
386
374
if ($ handle ) {
0 commit comments