From 2436e530484a346d0a246733519ceaa40b943bd6 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 13 Jan 2017 08:32:05 +0100 Subject: [PATCH] strict type fixes --- src/Caching/Cache.php | 4 ++-- src/Caching/Storages/SQLiteJournal.php | 2 -- tests/Storages/FileStorage.sliding.phpt | 2 +- tests/Storages/FileStorage.stress.phpt | 10 +++++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Caching/Cache.php b/src/Caching/Cache.php index 15b20e66..29f024c9 100644 --- a/src/Caching/Cache.php +++ b/src/Caching/Cache.php @@ -211,7 +211,7 @@ private function completeDependencies($dp) // convert FILES into CALLBACKS if (isset($dp[self::FILES])) { foreach (array_unique((array) $dp[self::FILES]) as $item) { - $dp[self::CALLBACKS][] = [[__CLASS__, 'checkFile'], $item, @filemtime($item)]; // @ - stat may fail + $dp[self::CALLBACKS][] = [[__CLASS__, 'checkFile'], $item, @filemtime($item) ?: NULL]; // @ - stat may fail } unset($dp[self::FILES]); } @@ -325,7 +325,7 @@ public function start($key) */ protected function generateKey($key) { - return $this->namespace . md5(is_scalar($key) ? $key : serialize($key)); + return $this->namespace . md5(is_scalar($key) ? (string) $key : serialize($key)); } diff --git a/src/Caching/Storages/SQLiteJournal.php b/src/Caching/Storages/SQLiteJournal.php index 6978a1fa..d1d163ea 100644 --- a/src/Caching/Storages/SQLiteJournal.php +++ b/src/Caching/Storages/SQLiteJournal.php @@ -95,8 +95,6 @@ public function write($key, array $dependencies) } $this->pdo->exec('COMMIT'); - - return TRUE; } diff --git a/tests/Storages/FileStorage.sliding.phpt b/tests/Storages/FileStorage.sliding.phpt index 5ad62bcb..187dfc1e 100644 --- a/tests/Storages/FileStorage.sliding.phpt +++ b/tests/Storages/FileStorage.sliding.phpt @@ -25,7 +25,7 @@ $cache->save($key, $value, [ ]); -for ($i = 0; $i < 5; $i++) { +for ($i = '0'; $i < '5'; $i++) { // Sleeping 1 second sleep(1); clearstatcache(); diff --git a/tests/Storages/FileStorage.stress.phpt b/tests/Storages/FileStorage.stress.phpt index 03f020e6..f0466eb7 100644 --- a/tests/Storages/FileStorage.stress.phpt +++ b/tests/Storages/FileStorage.stress.phpt @@ -1,7 +1,7 @@ write($i, randomStr(), []); + $storage->write((string) $i, randomStr(), []); } @@ -44,17 +44,17 @@ for ($i = 0; $i <= COUNT_FILES; $i++) { $hits = ['ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0]; for ($counter = 0; $counter < 1000; $counter++) { // write - $ok = $storage->write(rand(0, COUNT_FILES), randomStr(), []); + $ok = $storage->write((string) rand(0, COUNT_FILES), randomStr(), []); if ($ok === FALSE) { $hits['cantwrite']++; } // remove - //$ok = $storage->remove(rand(0, COUNT_FILES)); + //$ok = $storage->remove((string) rand(0, COUNT_FILES)); //if (!$ok) $hits['cantdelete']++; // read - $res = $storage->read(rand(0, COUNT_FILES)); + $res = $storage->read((string) rand(0, COUNT_FILES)); // compare if ($res === NULL) {