Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/Symfony/Component/Cache/Psr16Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

private ?\Closure $createCacheItem = null;
private ?CacheItem $cacheItemPrototype = null;
private static \Closure $packCacheItem;

public function __construct(CacheItemPoolInterface $pool)
{
Expand Down Expand Up @@ -66,15 +65,6 @@

return $createCacheItem($key, null, $allowInt)->set($value);
};
self::$packCacheItem ??= \Closure::bind(
static function (CacheItem $item) {
$item->newMetadata = $item->metadata;

return $item->pack();
},
null,
CacheItem::class
);
}

public function get($key, $default = null): mixed
Expand Down Expand Up @@ -156,20 +146,20 @@
}

foreach ($items as $key => $item) {
$values[$key] = $item->isHit() ? (self::$packCacheItem)($item) : $default;
$values[$key] = $item->isHit() ? $item->get() : $default;
}

return $values;
}

public function setMultiple($values, $ttl = null): bool

Check failure on line 155 in src/Symfony/Component/Cache/Psr16Cache.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnStatement

src/Symfony/Component/Cache/Psr16Cache.php:155:20: InvalidReturnStatement: The inferred type 'array<array-key, mixed>' does not match the declared return type 'iterable<string, mixed>' for Symfony\Component\Cache\Psr16Cache::getMultiple (see https://psalm.dev/128)

Check failure on line 155 in src/Symfony/Component/Cache/Psr16Cache.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnStatement

src/Symfony/Component/Cache/Psr16Cache.php:155:20: InvalidReturnStatement: The inferred type 'array<array-key, mixed>' does not match the declared return type 'iterable<string, mixed>' for Symfony\Component\Cache\Psr16Cache::getMultiple (see https://psalm.dev/128)
{
$valuesIsArray = \is_array($values);
if (!$valuesIsArray && !$values instanceof \Traversable) {
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given.', get_debug_type($values)));
}
$items = [];

Check failure on line 162 in src/Symfony/Component/Cache/Psr16Cache.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnStatement

src/Symfony/Component/Cache/Psr16Cache.php:162:16: InvalidReturnStatement: The inferred type 'array<array-key, mixed>' does not match the declared return type 'iterable<string, mixed>' for Symfony\Component\Cache\Psr16Cache::getMultiple (see https://psalm.dev/128)

Check failure on line 162 in src/Symfony/Component/Cache/Psr16Cache.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnStatement

src/Symfony/Component/Cache/Psr16Cache.php:162:16: InvalidReturnStatement: The inferred type 'array<array-key, mixed>' does not match the declared return type 'iterable<string, mixed>' for Symfony\Component\Cache\Psr16Cache::getMultiple (see https://psalm.dev/128)
try {
if (null !== $f = $this->createCacheItem) {
$valuesIsArray = false;
Expand Down
17 changes: 17 additions & 0 deletions src/Symfony/Component/Cache/Tests/Psr16CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Cache\IntegrationTests\SimpleCacheTest;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Cache\Psr16Cache;

Expand Down Expand Up @@ -172,6 +173,22 @@ protected function isPruned(CacheInterface $cache, string $name): bool

return !file_exists($getFileMethod->invoke($pool, $name));
}

public function testGetMultipleWithTagAwareAdapter()
{
if (isset($this->skippedTests[__FUNCTION__])) {
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
}

$cache = new Psr16Cache(new TagAwareAdapter(new FilesystemAdapter()));

$cache->set('foo', 'foo-val');
$cache->set('bar', 'bar-val');
$cache->set('baz', 'baz-val');
$cache->set('qux', 'qux-val');

$this->assertEquals(['foo' => 'foo-val', 'bar' => 'bar-val', 'baz' => 'baz-val', 'qux' => 'qux-val'], $cache->getMultiple(['foo', 'bar', 'baz', 'qux']));
}
}

class NotUnserializable
Expand Down
Loading