Skip to content

Commit 2436e53

Browse files
committed
strict type fixes
1 parent dab7b83 commit 2436e53

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/Caching/Cache.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function completeDependencies($dp)
211211
// convert FILES into CALLBACKS
212212
if (isset($dp[self::FILES])) {
213213
foreach (array_unique((array) $dp[self::FILES]) as $item) {
214-
$dp[self::CALLBACKS][] = [[__CLASS__, 'checkFile'], $item, @filemtime($item)]; // @ - stat may fail
214+
$dp[self::CALLBACKS][] = [[__CLASS__, 'checkFile'], $item, @filemtime($item) ?: NULL]; // @ - stat may fail
215215
}
216216
unset($dp[self::FILES]);
217217
}
@@ -325,7 +325,7 @@ public function start($key)
325325
*/
326326
protected function generateKey($key)
327327
{
328-
return $this->namespace . md5(is_scalar($key) ? $key : serialize($key));
328+
return $this->namespace . md5(is_scalar($key) ? (string) $key : serialize($key));
329329
}
330330

331331

src/Caching/Storages/SQLiteJournal.php

-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ public function write($key, array $dependencies)
9595
}
9696

9797
$this->pdo->exec('COMMIT');
98-
99-
return TRUE;
10098
}
10199

102100

tests/Storages/FileStorage.sliding.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $cache->save($key, $value, [
2525
]);
2626

2727

28-
for ($i = 0; $i < 5; $i++) {
28+
for ($i = '0'; $i < '5'; $i++) {
2929
// Sleeping 1 second
3030
sleep(1);
3131
clearstatcache();

tests/Storages/FileStorage.stress.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* Test: Nette\Caching\Storages\FileStorage sliding expiration test.
4+
* Test: Nette\Caching\Storages\FileStorage atomicity test.
55
* @multiple 5
66
*/
77

@@ -36,25 +36,25 @@ $storage = new FileStorage(TEMP_DIR);
3636

3737
// clear playground
3838
for ($i = 0; $i <= COUNT_FILES; $i++) {
39-
$storage->write($i, randomStr(), []);
39+
$storage->write((string) $i, randomStr(), []);
4040
}
4141

4242

4343
// test loop
4444
$hits = ['ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0];
4545
for ($counter = 0; $counter < 1000; $counter++) {
4646
// write
47-
$ok = $storage->write(rand(0, COUNT_FILES), randomStr(), []);
47+
$ok = $storage->write((string) rand(0, COUNT_FILES), randomStr(), []);
4848
if ($ok === FALSE) {
4949
$hits['cantwrite']++;
5050
}
5151

5252
// remove
53-
//$ok = $storage->remove(rand(0, COUNT_FILES));
53+
//$ok = $storage->remove((string) rand(0, COUNT_FILES));
5454
//if (!$ok) $hits['cantdelete']++;
5555

5656
// read
57-
$res = $storage->read(rand(0, COUNT_FILES));
57+
$res = $storage->read((string) rand(0, COUNT_FILES));
5858

5959
// compare
6060
if ($res === NULL) {

0 commit comments

Comments
 (0)