Skip to content

Commit

Permalink
Merge pull request #315 from boesing/bugfix/integerish-keys
Browse files Browse the repository at this point in the history
Allow integerish keys in methods handling multiple keys at once
  • Loading branch information
boesing authored Jun 15, 2024
2 parents afb7c19 + 0f993b7 commit bf83c2a
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 221 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"laminas/laminas-config-aggregator": "^1.13",
"laminas/laminas-serializer": "^3.0",
"phpunit/phpunit": "^9.5.27",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.4"
"psalm/plugin-phpunit": "^0.19.0",
"vimeo/psalm": "^5.24"
},
"conflict": {
"laminas/laminas-serializer": "<3.0",
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 1 addition & 40 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e">
<file src="src/Exception/BadMethodCallException.php">
<UnusedClass>
<code><![CDATA[BadMethodCallException]]></code>
Expand Down Expand Up @@ -119,11 +119,6 @@
<code><![CDATA[setUmask]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/Psr/SimpleCache/SimpleCacheDecorator.php">
<InvalidArgument>
<code><![CDATA[$values]]></code>
</InvalidArgument>
</file>
<file src="src/Service/StorageAdapterFactory.php">
<InvalidArgument>
<code><![CDATA[$pluginConfiguration]]></code>
Expand Down Expand Up @@ -460,10 +455,6 @@
<code><![CDATA[testSetShouldRaisePsrInvalidArgumentExceptionForInvalidKeys]]></code>
<code><![CDATA[testSetShouldRemoveItemFromCacheIfTtlIsBelow1]]></code>
</MissingReturnType>
<MixedInferredReturnType>
<code><![CDATA[array]]></code>
<code><![CDATA[array]]></code>
</MixedInferredReturnType>
</file>
<file src="test/Service/StorageAdapterFactoryFactoryTest.php">
<DeprecatedMethod>
Expand Down Expand Up @@ -499,43 +490,13 @@
<MixedMethodCall>
<code><![CDATA[getResult]]></code>
</MixedMethodCall>
<PossiblyNullReference>
<code><![CDATA[getNamespace]]></code>
<code><![CDATA[setKeyPattern]]></code>
<code><![CDATA[setKeyPattern]]></code>
<code><![CDATA[setKeyPattern]]></code>
<code><![CDATA[setNamespace]]></code>
<code><![CDATA[setNamespace]]></code>
<code><![CDATA[setReadable]]></code>
<code><![CDATA[setTtl]]></code>
<code><![CDATA[setTtl]]></code>
<code><![CDATA[setWritable]]></code>
</PossiblyNullReference>
<PossiblyUndefinedVariable>
<code><![CDATA[$success]]></code>
</PossiblyUndefinedVariable>
<PossiblyUnusedMethod>
<code><![CDATA[simpleEventHandlingMethodDefinitions]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Storage/Adapter/AdapterOptionsTest.php">
<PossiblyNullReference>
<code><![CDATA[getKeyPattern]]></code>
<code><![CDATA[getTtl]]></code>
<code><![CDATA[setAdapter]]></code>
<code><![CDATA[setFromArray]]></code>
<code><![CDATA[setKeyPattern]]></code>
<code><![CDATA[setKeyPattern]]></code>
<code><![CDATA[setNamespace]]></code>
<code><![CDATA[setReadable]]></code>
<code><![CDATA[setTtl]]></code>
<code><![CDATA[setTtl]]></code>
<code><![CDATA[setWritable]]></code>
</PossiblyNullReference>
<PossiblyUnusedProperty>
<code><![CDATA[$storage]]></code>
</PossiblyUnusedProperty>
</file>
<file src="test/Storage/Adapter/TestAsset/AdapterWithStorageAndEventsCapableInterface.php">
<MissingReturnType>
<code><![CDATA[addPlugin]]></code>
Expand Down
2 changes: 1 addition & 1 deletion src/Psr/CacheItemPool/CacheItemPoolDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getItems(array $keys = []): array
}

foreach ($cacheItems as $key => $value) {
$items[$key] = new CacheItem($key, $value, true, $this->clock);
$items[$key] = new CacheItem((string) $key, $value, true, $this->clock);
}

// Return empty items for any keys that where not found
Expand Down
4 changes: 2 additions & 2 deletions src/Psr/SimpleCache/SimpleCacheDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function setMultiple(iterable $values, int|DateInterval|null $ttl = null)
}

foreach ($result as $index => $key) {
if (! $this->storage->hasItem($key)) {
if (! $this->storage->hasItem((string) $key)) {
unset($result[$index]);
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public function deleteMultiple(iterable $keys): bool
}

foreach ($result as $index => $key) {
if (! $this->storage->hasItem($key)) {
if (! $this->storage->hasItem((string) $key)) {
unset($result[$index]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Storage/AbstractMetadataCapableAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ public function getMetadatas(array $keys): array
/**
* Internal method to get multiple metadata
*
* @param array<string> $normalizedKeys
* @return array<string,TMetadata> Associative array of keys and metadata
* @param array<non-empty-string|int> $normalizedKeys
* @return array<non-empty-string|int,TMetadata> Associative array of keys and metadata
* @throws ExceptionInterface
*/
protected function internalGetMetadatas(array $normalizedKeys): array
{
$result = [];
foreach ($normalizedKeys as $normalizedKey) {
$metadata = $this->internalGetMetadata($normalizedKey);
$metadata = $this->internalGetMetadata((string) $normalizedKey);
if ($metadata === null) {
continue;
}
Expand Down
Loading

0 comments on commit bf83c2a

Please sign in to comment.