@@ -83,10 +83,9 @@ public function __construct($dir, IJournal $journal = NULL)
8383
8484 /**
8585 * Read from cache.
86- * @param string
8786 * @return mixed
8887 */
89- public function read ($ key )
88+ public function read (string $ key )
9089 {
9190 $ meta = $ this ->readMetaAndLock ($ this ->getCacheFile ($ key ), LOCK_SH );
9291 if ($ meta && $ this ->verify ($ meta )) {
@@ -100,10 +99,8 @@ public function read($key)
10099
101100 /**
102101 * Verifies dependencies.
103- * @param array
104- * @return bool
105102 */
106- private function verify ($ meta )
103+ private function verify (array $ meta ): bool
107104 {
108105 do {
109106 if (!empty ($ meta [self ::META_DELTA ])) {
@@ -140,10 +137,9 @@ private function verify($meta)
140137
141138 /**
142139 * Prevents item reading and writing. Lock is released by write() or remove().
143- * @param string
144140 * @return void
145141 */
146- public function lock ($ key )
142+ public function lock (string $ key )
147143 {
148144 $ cacheFile = $ this ->getCacheFile ($ key );
149145 if ($ this ->useDirs && !is_dir ($ dir = dirname ($ cacheFile ))) {
@@ -159,11 +155,9 @@ public function lock($key)
159155
160156 /**
161157 * Writes item into the cache.
162- * @param string
163- * @param mixed
164158 * @return void
165159 */
166- public function write ($ key , $ data , array $ dp )
160+ public function write (string $ key , $ data , array $ dp )
167161 {
168162 $ meta = [
169163 self ::META_TIME => microtime (),
@@ -244,10 +238,9 @@ public function write($key, $data, array $dp)
244238
245239 /**
246240 * Removes item from the cache.
247- * @param string
248241 * @return void
249242 */
250- public function remove ($ key )
243+ public function remove (string $ key )
251244 {
252245 unset($ this ->locks [$ key ]);
253246 $ this ->delete ($ this ->getCacheFile ($ key ));
@@ -256,7 +249,6 @@ public function remove($key)
256249
257250 /**
258251 * Removes items from the cache by conditions & garbage collector.
259- * @param array conditions
260252 * @return void
261253 */
262254 public function clean (array $ conditions )
@@ -315,7 +307,7 @@ public function clean(array $conditions)
315307 * @param int lock mode
316308 * @return array|NULL
317309 */
318- protected function readMetaAndLock ($ file , $ lock )
310+ protected function readMetaAndLock (string $ file , int $ lock )
319311 {
320312 $ handle = @fopen ($ file , 'r+b ' ); // @ - file may not exist
321313 if (!$ handle ) {
@@ -342,10 +334,9 @@ protected function readMetaAndLock($file, $lock)
342334
343335 /**
344336 * Reads cache data from disk and closes cache file handle.
345- * @param array
346337 * @return mixed
347338 */
348- protected function readData ($ meta )
339+ protected function readData (array $ meta )
349340 {
350341 $ data = stream_get_contents ($ meta [self ::HANDLE ]);
351342 flock ($ meta [self ::HANDLE ], LOCK_UN );
@@ -361,10 +352,8 @@ protected function readData($meta)
361352
362353 /**
363354 * Returns file name.
364- * @param string
365- * @return string
366355 */
367- protected function getCacheFile ($ key )
356+ protected function getCacheFile (string $ key ): string
368357 {
369358 $ file = urlencode ($ key );
370359 if ($ this ->useDirs && $ a = strrpos ($ file , '%00 ' )) { // %00 = urlencode(Nette\Caching\Cache::NAMESPACE_SEPARATOR)
@@ -376,11 +365,10 @@ protected function getCacheFile($key)
376365
377366 /**
378367 * Deletes and closes file.
379- * @param string
380- * @param resource
368+ * @param resource $handle
381369 * @return void
382370 */
383- private static function delete ($ file , $ handle = NULL )
371+ private static function delete (string $ file , $ handle = NULL )
384372 {
385373 if (@unlink ($ file )) { // @ - file may not already exist
386374 if ($ handle ) {
0 commit comments