Skip to content

Commit 8d62394

Browse files
authored
Replace StyleCI with PHP CS Fixer (#137)
1 parent 756c264 commit 8d62394

30 files changed

Lines changed: 210 additions & 226 deletions

.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.0'

.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
@@ -22,3 +22,7 @@ phpunit.phar
2222
/phpunit.xml
2323
# local phpunit cache
2424
.phpunit.result.cache
25+
26+
# PHP CS Fixer
27+
/.php-cs-fixer.cache
28+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Finder;
6+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
7+
use Yiisoft\CodeStyle\ConfigBuilder;
8+
9+
$finder = (new Finder())->in([
10+
__DIR__ . '/config',
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
return ConfigBuilder::build()
16+
->setRiskyAllowed(true)
17+
->setParallelConfig(ParallelConfigFactory::detect())
18+
->setRules([
19+
'@Yiisoft/Core' => true,
20+
'@Yiisoft/Core:risky' => true,
21+
])
22+
->setFinder($finder);

.styleci.yml

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Enh #132: Add benchmarks, improve performance of `Message::parse()` (@samdark)
66
- Bug #130: Updated `Message::parse()` to correctly support multiple placeholders (@technicated)
77
- Chg #130, #133: Changed `Message::parse()` to conform to PSR-3 (@technicated, @vjik)
8+
- Enh #137: Explicitly import classes, functions, and constants in "use" section (@mspirkov)
89

910
## 2.2.0 December 13, 2025
1011

composer.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
"yiisoft/var-dumper": "^1.0"
3636
},
3737
"require-dev": {
38-
"maglnet/composer-require-checker": "^4.4",
38+
"bamarni/composer-bin-plugin": "^1.8.3",
39+
"friendsofphp/php-cs-fixer": "^3.93",
3940
"phpbench/phpbench": "^1.0",
4041
"phpunit/phpunit": "^9.6.23",
4142
"rector/rector": "^2.0.17",
4243
"roave/infection-static-analysis-plugin": "^1.25",
4344
"spatie/phpunit-watcher": "^1.23.6",
44-
"vimeo/psalm": "^4.30 || ^5.26.1 || ^6.12"
45+
"vimeo/psalm": "^4.30 || ^5.26.1 || ^6.12",
46+
"yiisoft/code-style": "^1.0"
4547
},
4648
"provide": {
4749
"psr/log-implementation": "1.0.0"
@@ -66,6 +68,11 @@
6668
}
6769
},
6870
"extra": {
71+
"bamarni-bin": {
72+
"bin-links": true,
73+
"forward-command": true,
74+
"target-directory": "tools"
75+
},
6976
"config-plugin-options": {
7077
"source-directory": "config"
7178
},
@@ -77,13 +84,15 @@
7784
"config": {
7885
"sort-packages": true,
7986
"allow-plugins": {
87+
"bamarni/composer-bin-plugin": true,
8088
"infection/extension-installer": true,
8189
"composer/package-versions-deprecated": true
8290
}
8391
},
8492
"scripts": {
8593
"test": "phpunit --testdox --no-interaction",
8694
"test-watch": "phpunit-watcher watch",
87-
"bench": "phpbench run --report=default"
95+
"bench": "phpbench run --report=default",
96+
"cs-fix": "php-cs-fixer fix"
8897
}
8998
}

src/ContextProvider/CommonContextProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ final class CommonContextProvider implements ContextProviderInterface
1111
{
1212
public function __construct(
1313
private array $data,
14-
) {
15-
}
14+
) {}
1615

1716
public function getContext(): array
1817
{

src/ContextProvider/CompositeContextProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class CompositeContextProvider implements ContextProviderInterface
1515
private array $providers;
1616

1717
public function __construct(
18-
ContextProviderInterface ...$providers
18+
ContextProviderInterface ...$providers,
1919
) {
2020
$this->providers = $providers;
2121
}

src/ContextProvider/SystemContextProvider.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
use InvalidArgumentException;
88
use Yiisoft\Log\Message;
99

10+
use function is_string;
11+
use function sprintf;
12+
13+
use const DEBUG_BACKTRACE_IGNORE_ARGS;
14+
1015
/**
1116
* @psalm-import-type TraceItem from Message
1217
*/
@@ -79,8 +84,8 @@ public function setExcludedTracePaths(array $excludedTracePaths): self
7984
throw new InvalidArgumentException(
8085
sprintf(
8186
'The trace path must be a string, %s received.',
82-
get_debug_type($excludedTracePath)
83-
)
87+
get_debug_type($excludedTracePath),
88+
),
8489
);
8590
}
8691
}
@@ -109,7 +114,7 @@ private function collectTrace(array $backtrace): array
109114
if (isset($trace['file'], $trace['line'])) {
110115
$excludedMatch = array_filter(
111116
$this->excludedTracePaths,
112-
static fn($path) => str_contains($trace['file'], $path)
117+
static fn($path) => str_contains($trace['file'], $path),
113118
);
114119

115120
if (empty($excludedMatch)) {

0 commit comments

Comments
 (0)