Skip to content

Commit 4cdad65

Browse files
authored
Replace StyleCI to PHP CS Fixer (#302)
1 parent 7359b97 commit 4cdad65

Some content is hidden

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

49 files changed

+291
-359
lines changed

.github/workflows/rector-cs.yml

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

.github/workflows/rector.yml

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

.gitignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ composer.phar
3434
/phpunit.xml
3535
/.phpunit.cache
3636

37-
# ignore dev installed apps and extensions
38-
/apps
39-
/extensions
40-
/packages
41-
42-
# NPM packages
43-
/node_modules
44-
.env
37+
# PHP CS Fixer
38+
/.php-cs-fixer.cache
39+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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__ . '/src',
11+
__DIR__ . '/tests',
12+
]);
13+
14+
return ConfigBuilder::build()
15+
->setRiskyAllowed(true)
16+
->setParallelConfig(ParallelConfigFactory::detect())
17+
->setRules([
18+
'@Yiisoft/Core' => true,
19+
'@Yiisoft/Core:risky' => true,
20+
])
21+
->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
@@ -6,6 +6,7 @@
66
- Bug #295: Remove unnecessary `CacheKeyNormalizer` instance creation in `CachedContent` (@samdark)
77
- Enh #295: Minor refactor `ViewTrait::getParameter()` and `ViewTrait::resolveViewFilePath()` (@samdark)
88
- Bug #300: Fix renderer selection for view files with double extensions (@vjik)
9+
- Enh #302: Explicitly import classes, functions, and constants in "use" section (@vjik)
910

1011
## 12.2.2 December 07, 2025
1112

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"rector/rector": "^2.3.4",
4343
"spatie/phpunit-watcher": "^1.24.4",
4444
"yiisoft/aliases": "^3.1.1",
45+
"yiisoft/code-style": "^1.0",
4546
"yiisoft/di": "^1.4.1",
4647
"yiisoft/psr-dummy-provider": "^1.0.2",
4748
"yiisoft/test-support": "^3.1.0"
@@ -83,6 +84,7 @@
8384
},
8485
"scripts": {
8586
"bench": "phpbench run",
87+
"cs-fix": "php-cs-fixer fix",
8688
"infection": "infection --threads=max",
8789
"test": "phpunit --testdox",
8890
"test-watch": "phpunit-watcher watch"

src/Cache/CachedContent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
private readonly string $id,
4141
private readonly CacheInterface $cache,
4242
array $dynamicContents = [],
43-
array $variations = []
43+
array $variations = [],
4444
) {
4545
$this->setDynamicContents($dynamicContents);
4646
$this->setVariations($variations);
@@ -61,8 +61,8 @@ public function __construct(
6161
public function cache(
6262
string $content,
6363
DateInterval|int|null $ttl = 60,
64-
Dependency|null $dependency = null,
65-
float $beta = 1.0
64+
?Dependency $dependency = null,
65+
float $beta = 1.0,
6666
): string {
6767
/** @psalm-suppress MixedArgument */
6868
return $this->replaceDynamicPlaceholders(

src/Cache/DynamicContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class DynamicContent
2222
public function __construct(
2323
private readonly string $id,
2424
callable $contentGenerator,
25-
private readonly array $parameters = []
25+
private readonly array $parameters = [],
2626
) {
2727
$this->contentGenerator = $contentGenerator;
2828
}

src/Event/View/AfterRender.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public function __construct(
2020
private readonly View $view,
2121
private readonly string $file,
2222
private readonly array $parameters,
23-
private readonly string $result
24-
) {
25-
}
23+
private readonly string $result,
24+
) {}
2625

2726
public function getView(): View
2827
{

0 commit comments

Comments
 (0)