Skip to content

Commit a7e73ea

Browse files
authored
Replace StyleCI with PHP CS Fixer (#73)
1 parent d72742f commit a7e73ea

16 files changed

Lines changed: 101 additions & 126 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
6666

6767
- name: Cache dependencies installed with composer
68-
uses: actions/cache@v2
68+
uses: actions/cache@v4
6969
with:
7070
path: ${{ env.COMPOSER_CACHE_DIR }}
7171
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}

.github/workflows/mutation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
5555

5656
- name: Cache dependencies installed with composer
57-
uses: actions/cache@v2
57+
uses: actions/cache@v4
5858
with:
5959
path: ${{ env.COMPOSER_CACHE_DIR }}
6060
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}

.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 & 21 deletions
This file was deleted.

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
5050

5151
- name: Cache dependencies installed with composer
52-
uses: actions/cache@v2
52+
uses: actions/cache@v4
5353
with:
5454
path: ${{ env.COMPOSER_CACHE_DIR }}
5555
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ phpunit.phar
3030
# phpunit cache
3131
.phpunit.result.cache
3232

33-
33+
# PHP CS Fixer
34+
/.php-cs-fixer.cache
35+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
])->notPath([
14+
'MockHelper.php'
15+
]);
16+
17+
// TODO: Update the configuration after raising the minimum PHP version
18+
return (new Config())
19+
->setRiskyAllowed(true)
20+
->setParallelConfig(ParallelConfigFactory::detect())
21+
->setRules([
22+
'@PER-CS2.0' => true,
23+
'nullable_type_declaration' => true,
24+
'operator_linebreak' => true,
25+
'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
26+
'single_class_element_per_statement' => true,
27+
'types_spaces' => true,
28+
'no_unused_imports' => true,
29+
'ordered_class_elements' => true,
30+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
31+
'declare_strict_types' => true,
32+
'native_function_invocation' => true,
33+
'native_constant_invocation' => true,
34+
'fully_qualified_strict_types' => [
35+
'import_symbols' => true
36+
],
37+
'global_namespace_import' => [
38+
'import_classes' => true,
39+
'import_constants' => true,
40+
'import_functions' => true,
41+
],
42+
])
43+
->setFinder($finder);

.styleci.yml

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

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
## 2.0.1 under development
44

55
- Enh #62: Remove unneeded casting to array in private method `Memcached::iterableToArray()` (@vjik)
6-
- Enh #62: Improve list of memcached server validation (@vjik)
6+
- Enh #62: Improve list of memcached server validation (@vjik)
7+
- Enh #73: Explicitly import classes and functions in "use" section (@mspirkov)
78

89
## 2.0.0 February 15, 2023
910

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"psr/simple-cache": "^2.0|^3.0"
3636
},
3737
"require-dev": {
38+
"friendsofphp/php-cs-fixer": "^3.66",
3839
"maglnet/composer-require-checker": "^4.4",
3940
"phpunit/phpunit": "^9.5",
4041
"rector/rector": "^2.0.3",

0 commit comments

Comments
 (0)