Skip to content

Commit

Permalink
strict type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 29, 2017
1 parent dab7b83 commit 2436e53
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Caching/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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));
}


Expand Down
2 changes: 0 additions & 2 deletions src/Caching/Storages/SQLiteJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ public function write($key, array $dependencies)
}

$this->pdo->exec('COMMIT');

return TRUE;
}


Expand Down
2 changes: 1 addition & 1 deletion tests/Storages/FileStorage.sliding.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions tests/Storages/FileStorage.stress.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Test: Nette\Caching\Storages\FileStorage sliding expiration test.
* Test: Nette\Caching\Storages\FileStorage atomicity test.
* @multiple 5
*/

Expand Down Expand Up @@ -36,25 +36,25 @@ $storage = new FileStorage(TEMP_DIR);

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


// test loop
$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) {
Expand Down

0 comments on commit 2436e53

Please sign in to comment.