Skip to content

Commit 5e3a3b5

Browse files
committed
Bump psalm, improve psalm types, baseline psalm false positives
Signed-off-by: Aleksei Khudiakov <aleksey@xerkus.pro>
1 parent 329fb6f commit 5e3a3b5

File tree

7 files changed

+52
-41
lines changed

7 files changed

+52
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.phpunit.result.cache
2+
/.psalm-cache
23
/docs/html/
34
/laminas-mkdoc-theme.tgz
45
/laminas-mkdoc-theme/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"laminas/laminas-cache-storage-adapter-test": "^2.0",
1919
"laminas/laminas-coding-standard": "~2.5.0",
2020
"psalm/plugin-phpunit": "^0.18.0",
21-
"vimeo/psalm": "^5.0.0"
21+
"vimeo/psalm": "^5.18"
2222
},
2323
"config": {
2424
"sort-packages": true,

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm-baseline.xml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
2+
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
33
<file src="src/Apcu.php">
4-
<LessSpecificReturnStatement occurrences="1">
5-
<code>parent::setOptions($options)</code>
6-
</LessSpecificReturnStatement>
7-
<MissingClosureParamType occurrences="1">
4+
<MissingClosureParamType>
85
<code>$event</code>
96
</MissingClosureParamType>
10-
<MixedArgument occurrences="4">
7+
<MixedArgument>
118
<code>$metadata</code>
129
<code>$metadata</code>
1310
<code>$normalizedKey</code>
14-
<code>$params['namespace_separator']</code>
11+
<code><![CDATA[$params['namespace_separator']]]></code>
1512
</MixedArgument>
16-
<MixedArgumentTypeCoercion occurrences="7">
13+
<MixedArgumentTypeCoercion>
1714
<code>$internalKey</code>
1815
<code>$internalKey</code>
1916
<code>$key</code>
@@ -22,10 +19,10 @@
2219
<code>$normalizedKeys</code>
2320
<code>$normalizedKeys</code>
2421
</MixedArgumentTypeCoercion>
25-
<MixedArrayAccess occurrences="1">
26-
<code>$params['namespace_separator']</code>
22+
<MixedArrayAccess>
23+
<code><![CDATA[$params['namespace_separator']]]></code>
2724
</MixedArrayAccess>
28-
<MixedAssignment occurrences="17">
25+
<MixedAssignment>
2926
<code>$bool</code>
3027
<code>$casToken</code>
3128
<code>$internalKeyValuePairs[$internalKey]</code>
@@ -39,61 +36,64 @@
3936
<code>$params</code>
4037
<code>$result</code>
4138
<code>$result[substr($internalKey, $prefixL)]</code>
42-
<code>$this-&gt;totalSpace</code>
39+
<code><![CDATA[$this->totalSpace]]></code>
4340
<code>$value</code>
4441
<code>$value</code>
4542
<code>$value</code>
4643
</MixedAssignment>
47-
<MixedInferredReturnType occurrences="3">
44+
<MixedInferredReturnType>
4845
<code>ApcuOptions</code>
4946
<code>int|float</code>
5047
<code>int|float</code>
5148
</MixedInferredReturnType>
52-
<MixedMethodCall occurrences="1">
49+
<MixedMethodCall>
5350
<code>getParams</code>
5451
</MixedMethodCall>
55-
<MixedOperand occurrences="4">
52+
<MixedOperand>
5653
<code>$normalizedKey</code>
5754
<code>$normalizedKey</code>
5855
<code>$normalizedKey</code>
59-
<code>$smaInfo['num_seg']</code>
56+
<code><![CDATA[$smaInfo['num_seg']]]></code>
6057
</MixedOperand>
61-
<MixedReturnStatement occurrences="4">
62-
<code>$smaInfo['avail_mem']</code>
63-
<code>$this-&gt;options</code>
64-
<code>$this-&gt;totalSpace</code>
65-
<code>$this-&gt;totalSpace</code>
58+
<MixedReturnStatement>
59+
<code><![CDATA[$smaInfo['avail_mem']]]></code>
60+
<code><![CDATA[$this->options]]></code>
61+
<code><![CDATA[$this->totalSpace]]></code>
62+
<code><![CDATA[$this->totalSpace]]></code>
6663
</MixedReturnStatement>
67-
<MoreSpecificImplementedParamType occurrences="2">
64+
<MoreSpecificImplementedParamType>
6865
<code>$options</code>
6966
<code>$options</code>
7067
</MoreSpecificImplementedParamType>
71-
<MoreSpecificReturnType occurrences="1">
72-
<code>Apcu</code>
73-
</MoreSpecificReturnType>
74-
<PropertyNotSetInConstructor occurrences="1">
68+
<PropertyNotSetInConstructor>
7569
<code>Apcu</code>
7670
</PropertyNotSetInConstructor>
77-
<RedundantCastGivenDocblockType occurrences="4">
71+
<RedundantCastGivenDocblockType>
7872
<code>(int) $value</code>
7973
<code>(int) $value</code>
8074
<code>(string) $namespace</code>
8175
<code>(string) $prefix</code>
8276
</RedundantCastGivenDocblockType>
83-
<UnusedVariable occurrences="1">
77+
<UnusedVariable>
8478
<code>$key</code>
8579
</UnusedVariable>
8680
</file>
8781
<file src="src/Apcu/AdapterPluginManagerDelegatorFactory.php">
88-
<InvalidArgument occurrences="1"/>
82+
<UnusedParam>
83+
<code>$container</code>
84+
<code>$name</code>
85+
</UnusedParam>
8986
</file>
9087
<file src="src/ApcuIterator.php">
91-
<RedundantCastGivenDocblockType occurrences="1">
88+
<RedundantCastGivenDocblockType>
9289
<code>(int) $mode</code>
9390
</RedundantCastGivenDocblockType>
9491
</file>
9592
<file src="src/ApcuOptions.php">
96-
<RedundantCastGivenDocblockType occurrences="1">
93+
<PossiblyUnusedMethod>
94+
<code>setNamespaceSeparator</code>
95+
</PossiblyUnusedMethod>
96+
<RedundantCastGivenDocblockType>
9797
<code>(string) $namespaceSeparator</code>
9898
</RedundantCastGivenDocblockType>
9999
</file>

psalm.xml.dist

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="1"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xmlns="https://getpsalm.org/schema/config"
6-
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7-
findUnusedPsalmSuppress="true"
3+
cacheDirectory="./.psalm-cache"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns="https://getpsalm.org/schema/config"
6+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7+
errorLevel="1"
8+
findUnusedPsalmSuppress="true"
9+
findUnusedCode="true"
10+
findUnusedBaselineEntry="true"
811
errorBaseline="psalm-baseline.xml"
912
>
1013
<projectFiles>

src/Apcu.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
use const APC_LIST_ACTIVE;
4646
use const PHP_SAPI;
4747

48+
/**
49+
* @implements IterableInterface<string, mixed>
50+
*/
4851
final class Apcu extends AbstractAdapter implements
4952
AvailableSpaceCapableInterface,
5053
ClearByNamespaceInterface,
@@ -84,7 +87,7 @@ public function __construct($options = null)
8487
*
8588
* @see getOptions()
8689
*
87-
* @param array|Traversable|ApcuOptions $options
90+
* @param array<string,mixed>|Traversable<string, mixed>|ApcuOptions $options
8891
* @return Apcu
8992
*/
9093
public function setOptions($options)
@@ -93,7 +96,8 @@ public function setOptions($options)
9396
$options = new ApcuOptions($options);
9497
}
9598

96-
return parent::setOptions($options);
99+
parent::setOptions($options);
100+
return $this;
97101
}
98102

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

240244
if (! $success) {
241-
return;
245+
return null;
242246
}
243247

244248
$casToken = $result;

src/ApcuIterator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use function strlen;
1313
use function substr;
1414

15+
/**
16+
* @implements IteratorInterface<string,mixed>
17+
*/
1518
final class ApcuIterator implements IteratorInterface
1619
{
1720
/**

0 commit comments

Comments
 (0)