Skip to content

Commit

Permalink
Fix psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rimvydas-zilinskas committed Sep 1, 2022
1 parent ab53e21 commit 128ae76
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Pattern/CallbackCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function call($callback, array $args = [])
$cacheOutput = $options->getCacheOutput();
if ($cacheOutput) {
ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
}

// TODO: do not cache on errors using [set|restore]_error_handler
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/CaptureCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function start($pageId = null)
return false;
});

ob_implicit_flush(0);
ob_implicit_flush(false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/OutputCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function start($key)
}

ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
$this->keyStack[] = $key;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Psr/CacheItemPool/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function expiresAfter($time): static
$time = $interval;
}

/** @psalm-suppress RedundantConditionGivenDocblockType Until we do have native type-hints we should keep verifying this. */
/** @psalm-suppress RedundantCondition Until we do have native type-hints we should keep verifying this. */
if ($time instanceof DateInterval) {
$now = $this->clock->now();
return $this->expiresAt($now->add($time));
Expand Down
4 changes: 2 additions & 2 deletions test/Pattern/CallbackCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function executeCallbackAndMakeAssertions($callback, array $args): voi
$firstCounter = TestCallbackCache::$fooCounter + 1;

ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
$return = $this->pattern->call($callback, $args);
$data = ob_get_clean();

Expand All @@ -126,7 +126,7 @@ protected function executeCallbackAndMakeAssertions($callback, array $args): voi

// second call - cached
ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
$return = $this->pattern->call($callback, $args);
$data = ob_get_clean();

Expand Down
4 changes: 2 additions & 2 deletions test/Pattern/ObjectCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function executeMethodAndMakeAssertions(string $method, array $args):
$firstCounter = TestObjectCache::$fooCounter + 1;

ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
$return = $callback(...$args);
$data = ob_get_contents();
ob_end_clean();
Expand All @@ -140,7 +140,7 @@ protected function executeMethodAndMakeAssertions(string $method, array $args):

// second call - cached
ob_start();
ob_implicit_flush(0);
ob_implicit_flush(false);
$return = $callback(...$args);
$data = ob_get_contents();
ob_end_clean();
Expand Down
17 changes: 16 additions & 1 deletion test/Psr/CacheItemPool/CacheItemPoolDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ public function testGetNonexistentItems(): void
->willReturn([]);

$adapter = $this->getAdapter($storage);
$items = $adapter->getItems($keys);
/**
* @var array<string, CacheItem> $items
*/
$items = $adapter->getItems($keys);
self::assertEquals($keys, array_keys($items));
foreach ($keys as $key) {
self::assertEquals($key, $items[$key]->getKey());
Expand Down Expand Up @@ -268,6 +271,9 @@ public function testGetMixedItems(): void
->with($keys)
->willReturn(['bar' => 'value']);

/**
* @var array<string, CacheItem> $items
*/
$items = $this->getAdapter($storage)->getItems($keys);
self::assertCount(2, $items);
self::assertNull($items['foo']->get());
Expand Down Expand Up @@ -295,6 +301,9 @@ public function testGetItemsRuntimeExceptionIsMiss(): void
->with($keys)
->willThrowException(new Exception\RuntimeException());

/**
* @var array<string, CacheItem> $items
*/
$items = $this->getAdapter($storage)->getItems($keys);
self::assertCount(2, $items);
foreach ($keys as $key) {
Expand Down Expand Up @@ -338,6 +347,9 @@ public function testSaveItem(): void
$item = $adapter->getItem('foo');
$item->set('bar');
self::assertTrue($adapter->save($item));
/**
* @var array<string, CacheItem> $saved
*/
$saved = $adapter->getItems(['foo']);
self::assertEquals('bar', $saved['foo']->get());
self::assertTrue($saved['foo']->isHit());
Expand Down Expand Up @@ -376,6 +388,9 @@ public function testSaveItemWithExpiration(): void
$item->set('bar');
$item->expiresAfter(3600);
self::assertTrue($adapter->save($item));
/**
* @var array<string, CacheItem> $saved
*/
$saved = $adapter->getItems(['foo']);
self::assertEquals('bar', $saved['foo']->get());
self::assertTrue($saved['foo']->isHit());
Expand Down

0 comments on commit 128ae76

Please sign in to comment.