Skip to content

Commit 9cd8766

Browse files
authored
Replace StyleCI with PHP CS Fixer (#153)
1 parent f74a9a7 commit 9cd8766

41 files changed

Lines changed: 325 additions & 354 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rector-cs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Rector + PHP CS Fixer
2+
3+
on:
4+
pull_request_target:
5+
paths:
6+
- 'config/**'
7+
- 'src/**'
8+
- 'tests/**'
9+
- '.github/workflows/rector-cs.yml'
10+
- 'composer.json'
11+
- 'rector.php'
12+
- '.php-cs-fixer.dist.php'
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
rector:
23+
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
24+
secrets:
25+
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
26+
with:
27+
repository: ${{ github.event.pull_request.head.repo.full_name }}
28+
php: '8.1'

.github/workflows/rector.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ composer.phar
2626
/phpunit.phar
2727
/phpunit.xml
2828
/.phpunit.cache
29+
30+
# PHP CS Fixer
31+
/.php-cs-fixer.cache
32+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
$finder = (new Finder())->in([
10+
__DIR__ . '/config',
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
return (new Config())
16+
->setRiskyAllowed(true)
17+
->setParallelConfig(ParallelConfigFactory::detect())
18+
->setRules([
19+
'@PER-CS3.0' => true,
20+
'no_unused_imports' => true,
21+
'ordered_class_elements' => true,
22+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
23+
'declare_strict_types' => true,
24+
'native_function_invocation' => true,
25+
'native_constant_invocation' => true,
26+
'fully_qualified_strict_types' => [
27+
'import_symbols' => true
28+
],
29+
'global_namespace_import' => [
30+
'import_classes' => true,
31+
'import_constants' => true,
32+
'import_functions' => true,
33+
],
34+
])
35+
->setFinder($finder);

.styleci.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 3.2.1 under development
44

5-
- no changes in this release.
5+
- Enh #153: Explicitly import classes and functions in "use" section (@mspirkov)
66

77
## 3.2.0 December 11, 2025
88

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"psr/simple-cache": "^2.0 || ^3.0"
3434
},
3535
"require-dev": {
36+
"friendsofphp/php-cs-fixer": "^3.92.5",
3637
"maglnet/composer-require-checker": "^4.7.1",
3738
"phpunit/phpunit": "^10.5.46",
3839
"rector/rector": "^2.0.17",

config/di.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
declare(strict_types=1);
44

5+
use Yiisoft\Cache\ArrayCache;
6+
use Yiisoft\Cache\Cache;
7+
use Yiisoft\Cache\CacheInterface as YiisoftCacheInterface;
8+
use Psr\SimpleCache\CacheInterface as PsrCacheInterface;
9+
510
return [
6-
Yiisoft\Cache\CacheInterface::class => Yiisoft\Cache\Cache::class,
7-
Psr\SimpleCache\CacheInterface::class => Yiisoft\Cache\ArrayCache::class,
11+
YiisoftCacheInterface::class => Cache::class,
12+
PsrCacheInterface::class => ArrayCache::class,
813
];

src/ArrayCache.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use DateInterval;
88
use Traversable;
99
use Yiisoft\Cache\Exception\InvalidArgumentException;
10+
use Psr\SimpleCache\CacheInterface;
1011

1112
use function array_keys;
1213
use function array_map;
@@ -19,9 +20,9 @@
1920
/**
2021
* ArrayCache provides caching for the current request only by storing the values in an array.
2122
*
22-
* See {@see \Psr\SimpleCache\CacheInterface} for common cache operations that ArrayCache supports.
23+
* See {@see CacheInterface} for common cache operations that ArrayCache supports.
2324
*/
24-
final class ArrayCache implements \Psr\SimpleCache\CacheInterface
25+
final class ArrayCache implements CacheInterface
2526
{
2627
private const EXPIRATION_INFINITY = 0;
2728
private const EXPIRATION_EXPIRED = -1;
@@ -44,7 +45,7 @@ public function get(string $key, mixed $default = null): mixed
4445
return $default;
4546
}
4647

47-
public function set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool
48+
public function set(string $key, mixed $value, int|DateInterval|null $ttl = null): bool
4849
{
4950
$this->validateKey($key);
5051
$expiration = $this->ttlToExpiration(Ttl::from($ttl));
@@ -89,7 +90,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
8990
return $results;
9091
}
9192

92-
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
93+
public function setMultiple(iterable $values, int|DateInterval|null $ttl = null): bool
9394
{
9495
$values = $this->iterableToArray($values);
9596
$this->validateKeysOfValues($values);

src/Cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* PSR-16 {@see \Psr\SimpleCache\CacheInterface} instance passed to constructor.
2121
* You can use PSR-16 methods via {@see Cache::psr()}.
2222
*
23-
* @see \Yiisoft\Cache\CacheInterface
23+
* @see CacheInterface
2424
*/
2525
final class Cache implements CacheInterface
2626
{
@@ -62,8 +62,8 @@ public function getOrSet(
6262
mixed $key,
6363
callable $callable,
6464
DateInterval|int|null $ttl = null,
65-
Dependency|null $dependency = null,
66-
float $beta = 1.0
65+
?Dependency $dependency = null,
66+
float $beta = 1.0,
6767
) {
6868
$ttlObj = Ttl::from($ttl ?? $this->defaultTtl);
6969

@@ -132,7 +132,7 @@ private function setAndGet(
132132
string $key,
133133
callable $callable,
134134
Ttl|DateInterval|int|null $ttl,
135-
?Dependency $dependency
135+
?Dependency $dependency,
136136
): mixed {
137137
$ttl = Ttl::from($ttl ?? $this->defaultTtl);
138138
$value = $callable($this->psr);

0 commit comments

Comments
 (0)