Skip to content

Commit

Permalink
Fix psalm (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Feb 8, 2024
1 parent 5ef9822 commit 869f6f9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'phpunit.xml.dist'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -28,4 +30,12 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1']
['8.1', '8.2', '8.3']
psalm80:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm80.xml
os: >-
['ubuntu-latest']
php: >-
['8.0']
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"rector/rector": "^1.0.0",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.1"
"vimeo/psalm": "^4.30|^5.21"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 6 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
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"
Expand All @@ -12,4 +13,8 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 19 additions & 0 deletions psalm80.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
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"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
7 changes: 0 additions & 7 deletions src/SimpleCache/MemorySimpleCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function get(string $key, mixed $default = null): mixed
{
$this->validateKey($key);
if (array_key_exists($key, $this->cache) && !$this->isExpired($key)) {
/** @psalm-var mixed $value */
$value = $this->cache[$key][0];
if (is_object($value)) {
$value = clone $value;
Expand Down Expand Up @@ -81,7 +80,6 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
/** @psalm-var string[] $keys */
$result = [];
foreach ($keys as $key) {
/** @psalm-var mixed */
$result[$key] = $this->get($key, $default);
}
return $result;
Expand All @@ -91,9 +89,6 @@ public function setMultiple(iterable $values, null|int|DateInterval $ttl = null)
{
$values = $this->iterableToArray($values);
$this->validateKeysOfValues($values);
/**
* @psalm-var mixed $value
*/
foreach ($values as $key => $value) {
$this->set((string) $key, $value, $ttl);
}
Expand Down Expand Up @@ -127,7 +122,6 @@ public function getValues(): array
{
$result = [];
foreach ($this->cache as $key => $value) {
/** @psalm-var mixed */
$result[$key] = $value[0];
}
return $result;
Expand Down Expand Up @@ -197,7 +191,6 @@ private function validateKey(mixed $key): void
*/
private function validateKeys(array $keys): void
{
/** @psalm-var mixed $key */
foreach ($keys as $key) {
$this->validateKey($key);
}
Expand Down
3 changes: 0 additions & 3 deletions src/SimpleCache/SimpleCacheActionLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function set(string $key, mixed $value, null|int|DateInterval $ttl = null
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
$keys = $this->iterableToArray($keys);
/** @var mixed $key */
foreach ($keys as $key) {
$this->actions[] = Action::createGetAction($key);
}
Expand All @@ -71,7 +70,6 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
{
$values = $this->iterableToArray($values);
/** @psalm-var mixed $value */
foreach ($values as $key => $value) {
$this->actions[] = Action::createSetAction($key, $value, $ttl);
}
Expand All @@ -81,7 +79,6 @@ public function setMultiple(iterable $values, null|int|DateInterval $ttl = null)
public function deleteMultiple(iterable $keys): bool
{
$keys = $this->iterableToArray($keys);
/** @var mixed $key */
foreach ($keys as $key) {
$this->actions[] = Action::createDeleteAction($key);
}
Expand Down

0 comments on commit 869f6f9

Please sign in to comment.