Skip to content

Commit

Permalink
Bump psalm, improve psalm types, baseline psalm false positives
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksei Khudiakov <[email protected]>
  • Loading branch information
Xerkus committed Jan 7, 2024
1 parent 329fb6f commit 5e3a3b5
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.phpunit.result.cache
/.psalm-cache
/docs/html/
/laminas-mkdoc-theme.tgz
/laminas-mkdoc-theme/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"laminas/laminas-cache-storage-adapter-test": "^2.0",
"laminas/laminas-coding-standard": "~2.5.0",
"psalm/plugin-phpunit": "^0.18.0",
"vimeo/psalm": "^5.0.0"
"vimeo/psalm": "^5.18"
},
"config": {
"sort-packages": true,
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

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

62 changes: 31 additions & 31 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<file src="src/Apcu.php">
<LessSpecificReturnStatement occurrences="1">
<code>parent::setOptions($options)</code>
</LessSpecificReturnStatement>
<MissingClosureParamType occurrences="1">
<MissingClosureParamType>
<code>$event</code>
</MissingClosureParamType>
<MixedArgument occurrences="4">
<MixedArgument>
<code>$metadata</code>
<code>$metadata</code>
<code>$normalizedKey</code>
<code>$params['namespace_separator']</code>
<code><![CDATA[$params['namespace_separator']]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="7">
<MixedArgumentTypeCoercion>
<code>$internalKey</code>
<code>$internalKey</code>
<code>$key</code>
Expand All @@ -22,10 +19,10 @@
<code>$normalizedKeys</code>
<code>$normalizedKeys</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess occurrences="1">
<code>$params['namespace_separator']</code>
<MixedArrayAccess>
<code><![CDATA[$params['namespace_separator']]]></code>
</MixedArrayAccess>
<MixedAssignment occurrences="17">
<MixedAssignment>
<code>$bool</code>
<code>$casToken</code>
<code>$internalKeyValuePairs[$internalKey]</code>
Expand All @@ -39,61 +36,64 @@
<code>$params</code>
<code>$result</code>
<code>$result[substr($internalKey, $prefixL)]</code>
<code>$this-&gt;totalSpace</code>
<code><![CDATA[$this->totalSpace]]></code>
<code>$value</code>
<code>$value</code>
<code>$value</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="3">
<MixedInferredReturnType>
<code>ApcuOptions</code>
<code>int|float</code>
<code>int|float</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="1">
<MixedMethodCall>
<code>getParams</code>
</MixedMethodCall>
<MixedOperand occurrences="4">
<MixedOperand>
<code>$normalizedKey</code>
<code>$normalizedKey</code>
<code>$normalizedKey</code>
<code>$smaInfo['num_seg']</code>
<code><![CDATA[$smaInfo['num_seg']]]></code>
</MixedOperand>
<MixedReturnStatement occurrences="4">
<code>$smaInfo['avail_mem']</code>
<code>$this-&gt;options</code>
<code>$this-&gt;totalSpace</code>
<code>$this-&gt;totalSpace</code>
<MixedReturnStatement>
<code><![CDATA[$smaInfo['avail_mem']]]></code>
<code><![CDATA[$this->options]]></code>
<code><![CDATA[$this->totalSpace]]></code>
<code><![CDATA[$this->totalSpace]]></code>
</MixedReturnStatement>
<MoreSpecificImplementedParamType occurrences="2">
<MoreSpecificImplementedParamType>
<code>$options</code>
<code>$options</code>
</MoreSpecificImplementedParamType>
<MoreSpecificReturnType occurrences="1">
<code>Apcu</code>
</MoreSpecificReturnType>
<PropertyNotSetInConstructor occurrences="1">
<PropertyNotSetInConstructor>
<code>Apcu</code>
</PropertyNotSetInConstructor>
<RedundantCastGivenDocblockType occurrences="4">
<RedundantCastGivenDocblockType>
<code>(int) $value</code>
<code>(int) $value</code>
<code>(string) $namespace</code>
<code>(string) $prefix</code>
</RedundantCastGivenDocblockType>
<UnusedVariable occurrences="1">
<UnusedVariable>
<code>$key</code>
</UnusedVariable>
</file>
<file src="src/Apcu/AdapterPluginManagerDelegatorFactory.php">
<InvalidArgument occurrences="1"/>
<UnusedParam>
<code>$container</code>
<code>$name</code>
</UnusedParam>
</file>
<file src="src/ApcuIterator.php">
<RedundantCastGivenDocblockType occurrences="1">
<RedundantCastGivenDocblockType>
<code>(int) $mode</code>
</RedundantCastGivenDocblockType>
</file>
<file src="src/ApcuOptions.php">
<RedundantCastGivenDocblockType occurrences="1">
<PossiblyUnusedMethod>
<code>setNamespaceSeparator</code>
</PossiblyUnusedMethod>
<RedundantCastGivenDocblockType>
<code>(string) $namespaceSeparator</code>
</RedundantCastGivenDocblockType>
</file>
Expand Down
13 changes: 8 additions & 5 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedPsalmSuppress="true"
cacheDirectory="./.psalm-cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
findUnusedPsalmSuppress="true"
findUnusedCode="true"
findUnusedBaselineEntry="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
Expand Down
10 changes: 7 additions & 3 deletions src/Apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
use const APC_LIST_ACTIVE;
use const PHP_SAPI;

/**
* @implements IterableInterface<string, mixed>
*/
final class Apcu extends AbstractAdapter implements
AvailableSpaceCapableInterface,
ClearByNamespaceInterface,
Expand Down Expand Up @@ -84,7 +87,7 @@ public function __construct($options = null)
*
* @see getOptions()
*
* @param array|Traversable|ApcuOptions $options
* @param array<string,mixed>|Traversable<string, mixed>|ApcuOptions $options
* @return Apcu
*/
public function setOptions($options)
Expand All @@ -93,7 +96,8 @@ public function setOptions($options)
$options = new ApcuOptions($options);
}

return parent::setOptions($options);
parent::setOptions($options);
return $this;
}

/**
Expand Down Expand Up @@ -238,7 +242,7 @@ protected function internalGetItem(&$normalizedKey, &$success = null, &$casToken
$result = apcu_fetch($internalKey, $success);

if (! $success) {
return;
return null;
}

$casToken = $result;
Expand Down
3 changes: 3 additions & 0 deletions src/ApcuIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use function strlen;
use function substr;

/**
* @implements IteratorInterface<string,mixed>
*/
final class ApcuIterator implements IteratorInterface
{
/**
Expand Down

0 comments on commit 5e3a3b5

Please sign in to comment.