Skip to content

Commit 76a641a

Browse files
authored
Replace StyleCI to PHP CS Fixer (#283)
1 parent 633a770 commit 76a641a

19 files changed

+84
-148
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Rector + PHP CS Fixer
2+
13
on:
24
pull_request_target:
35
paths-ignore:
@@ -9,16 +11,18 @@ on:
911
- 'infection.json.dist'
1012
- 'psalm.xml'
1113

12-
name: rector
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
1320

1421
jobs:
1522
rector:
16-
uses: yiisoft/actions/.github/workflows/rector.yml@master
23+
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
1724
secrets:
1825
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
1926
with:
2027
repository: ${{ github.event.pull_request.head.repo.full_name }}
21-
os: >-
22-
['ubuntu-latest']
23-
php: >-
24-
['8.4']
28+
php: '8.1'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ phpunit.phar
2929
# phpunit cache
3030
.phpunit.result.cache
3131
/.phpunit.cache
32+
33+
# PHP CS Fixer
34+
/.php-cs-fixer.cache

.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\Config;
6+
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
$finder = (new Finder())->in([
10+
__DIR__ . '/src',
11+
__DIR__ . '/tests',
12+
]);
13+
14+
return (new Config())
15+
->setParallelConfig(ParallelConfigFactory::detect())
16+
->setRules([
17+
'@PER-CS3.0' => true,
18+
'no_unused_imports' => true,
19+
'ordered_class_elements' => true,
20+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
21+
])
22+
->setFinder($finder);

.styleci.yml

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

CHANGELOG.md

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

33
## 2.1.1 under development
44

5-
- no changes in this release.
5+
- Enh #282: Add PHP 8.5 support (@vjik)
66

77
## 2.1.0 April 04, 2025
88

99
- New #275: Add optional `$clock` parameter to `Manager` constructor to get current time (@vjik)
10-
- Chg #276, #282: Change PHP constraint in `composer.json` to `8.1 - 8.5` (@vjik)
10+
- Chg #276: Change PHP constraint in `composer.json` to `8.1 - 8.4` (@vjik)
1111
- Bug #264: Fix bug when default roles were not checked in `Manager::userHasPermission()` (@KovYu, @arogachev)
1212

1313
## 2.0.0 March 07, 2024

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"yiisoft/friendly-exception": "^1.1"
3333
},
3434
"require-dev": {
35+
"friendsofphp/php-cs-fixer": "^3.91",
3536
"maglnet/composer-require-checker": "^4.7.1",
3637
"phpunit/phpunit": "^10.5.45",
3738
"psr/clock": "^1.0",
@@ -74,6 +75,7 @@
7475
}
7576
},
7677
"scripts": {
78+
"cs-fix": "php-cs-fixer fix",
7779
"test": "phpunit --testdox --no-interaction",
7880
"test-watch": "phpunit-watcher watch"
7981
}

src/Assignment.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public function __construct(
2020
private readonly string $userId,
2121
private string $itemName,
2222
private readonly int $createdAt,
23-
) {
24-
}
23+
) {}
2524

2625
public function getUserId(): string
2726
{

src/CompositeRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function __construct(
3737
sprintf(
3838
'Operator could be either %1$s::AND or %1$s::OR, "%2$s" given.',
3939
self::class,
40-
$operator
41-
)
40+
$operator,
41+
),
4242
);
4343
}
4444
}

src/Exception/RuleInterfaceNotImplementedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function __construct(string $name, int $code = 0, ?Throwable $previous =
1717
parent::__construct(
1818
"Rule \"$name\" must implement \"$interfaceName\".",
1919
$code,
20-
$previous
20+
$previous,
2121
);
2222
}
2323
}

src/Item.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ abstract class Item
4343
/**
4444
* @param string $name The name of the item. This must be globally unique.
4545
*/
46-
final public function __construct(private string $name)
47-
{
48-
}
46+
final public function __construct(private string $name) {}
4947

5048
/**
5149
* @return string Type of the item.

0 commit comments

Comments
 (0)