Skip to content

Commit

Permalink
Minor refactoring + Fix psalm + Remove scrutinizer (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Feb 18, 2024
1 parent df12c36 commit 85767c4
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 47 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/static.yml
Expand Up @@ -30,13 +30,8 @@ jobs:

strategy:
matrix:
os:
- ubuntu-latest

php:
- 8.0
- 8.1
- 8.2
os: ['ubuntu-latest']
php: ['8.0', '8.1', '8.2', '8.3']

steps:
- name: Checkout
Expand Down Expand Up @@ -66,5 +61,10 @@ jobs:
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Static analysis
run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize
- name: Static analysis PHP 8.0
if: matrix.php == '8.0'
run: vendor/bin/psalm --config=psalm80.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}

- name: Static analysis PHP 8.1+
if: matrix.php != '8.0'
run: vendor/bin/psalm --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
31 changes: 0 additions & 31 deletions .scrutinizer.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

## 2.0.1 under development

- no changes in this release.
- Enh #30: Remove unneeded casting to array in private method `RedisCache::iterableToArray()` (@vjik)

## 2.0.0 July 10, 2023

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,7 +27,7 @@ implements [PSR-16](https://www.php-fig.org/psr/psr-16/) cache.
The package could be installed with composer:

```shell
composer require yiisoft/cache-redis --prefer-dist
composer require yiisoft/cache-redis
```

## General usage
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -40,7 +40,7 @@
"rector/rector": "^1.0.1",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30 || ^5.13"
"vimeo/psalm": "^4.30 || ^5.22"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml
Expand Up @@ -9,5 +9,12 @@
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 19 additions & 0 deletions psalm80.xml
@@ -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>
8 changes: 4 additions & 4 deletions src/RedisCache.php
Expand Up @@ -157,7 +157,6 @@ public function setMultiple(iterable $values, null|int|DateInterval $ttl = null)
return $this->deleteMultiple($keys);
}

/** @var mixed $value */
foreach ($values as $key => $value) {
$serializeValues[$key] = serialize($value);
}
Expand Down Expand Up @@ -236,12 +235,13 @@ private function normalizeTtl(null|int|string|DateInterval $ttl): ?int
/**
* Converts iterable to array.
*
* @return array
* @psalm-template T
* @psalm-param iterable<T> $iterable
* @psalm-return array<array-key,T>
*/
private function iterableToArray(iterable $iterable): array
{
/** @psalm-suppress RedundantCast */
return $iterable instanceof Traversable ? iterator_to_array($iterable) : (array) $iterable;
return $iterable instanceof Traversable ? iterator_to_array($iterable) : $iterable;
}

/**
Expand Down

0 comments on commit 85767c4

Please sign in to comment.