Skip to content

Commit eaa6168

Browse files
authored
Replace StyleCI to PHP CS Fixer (#786)
1 parent 7e3e821 commit eaa6168

169 files changed

Lines changed: 876 additions & 987 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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.5']
28+
php: '8.1'

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ composer.phar
2727
/phpunit.xml
2828
/.phpunit.cache
2929

30+
# PHP CS Fixer
31+
/.php-cs-fixer.cache
32+
3033
# po4a .mo files
31-
*.mo
34+
*.mo

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

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
},
4040
"require-dev": {
4141
"bamarni/composer-bin-plugin": "^1.8.3",
42+
"friendsofphp/php-cs-fixer": "^3.91",
4243
"jetbrains/phpstorm-attributes": "^1.2",
4344
"maglnet/composer-require-checker": "^4.7.1",
4445
"phpbench/phpbench": "^1.4.1",
@@ -93,6 +94,7 @@
9394
"rector": "vendor/bin/rector process",
9495
"infection": "vendor/bin/infection",
9596
"dry-run": "vendor/bin/rector process --dry-run",
96-
"psalm": "vendor/bin/psalm --config=psalm.xml"
97+
"psalm": "vendor/bin/psalm --config=psalm.xml",
98+
"cs-fix": "php-cs-fixer fix"
9799
}
98100
}

src/CountableLimitInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface CountableLimitInterface
2020
*
2121
* @see getLessThanMinMessage() for related error message.
2222
*/
23-
public function getMin(): int|null;
23+
public function getMin(): ?int;
2424

2525
/**
2626
* Returns current maximum limit.
@@ -29,7 +29,7 @@ public function getMin(): int|null;
2929
*
3030
* @see getGreaterThanMaxMessage() for related error message.
3131
*/
32-
public function getMax(): int|null;
32+
public function getMax(): ?int;
3333

3434
/**
3535
* Returns current "exactly" value meant for strict comparison. It is a shortcut for the case when {@see getMin()}
@@ -40,7 +40,7 @@ public function getMax(): int|null;
4040
*
4141
* @see getNotExactlyMessage() for related error message
4242
*/
43-
public function getExactly(): int|null;
43+
public function getExactly(): ?int;
4444

4545
/**
4646
* Returns message used when a validated value is less than minimum set in {@see getMin()}.

src/DataSet/ArrayDataSet.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public function __construct(
2727
* @var array A mapping between property names and their values.
2828
*/
2929
private array $data = [],
30-
) {
31-
}
30+
) {}
3231

3332
/**
3433
* Returns a property value by its name.

src/DataSet/ObjectDataSet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,17 @@ public function __construct(
188188
* @var object An object containing rules and data.
189189
*/
190190
private readonly object $object,
191-
int $propertyVisibility = ReflectionProperty::IS_PRIVATE |
192-
ReflectionProperty::IS_PROTECTED |
193-
ReflectionProperty::IS_PUBLIC,
191+
int $propertyVisibility = ReflectionProperty::IS_PRIVATE
192+
| ReflectionProperty::IS_PROTECTED
193+
| ReflectionProperty::IS_PUBLIC,
194194
bool $useCache = true,
195195
) {
196196
$this->dataSetProvided = $this->object instanceof DataSetInterface;
197197
$this->rulesProvided = $this->object instanceof RulesProviderInterface;
198198
$this->parser = new ObjectParser(
199199
source: $object,
200200
propertyVisibility: $propertyVisibility,
201-
useCache: $useCache
201+
useCache: $useCache,
202202
);
203203
}
204204

src/DataSet/SingleValueDataSet.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public function __construct(
3333
* @var mixed Single value of any (mixed) data type.
3434
*/
3535
private readonly mixed $value,
36-
) {
37-
}
36+
) {}
3837

3938
/**
4039
* Returns a property value by its name. {@see SingleValueDataSet} does not support properties so `null` is always

src/Debug/ValidatorCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getSummary(): array
4646
}
4747

4848
$count = count($this->validations);
49-
$countValid = count(array_filter($this->validations, fn (array $data): bool => (bool)$data['result']));
49+
$countValid = count(array_filter($this->validations, fn(array $data): bool => (bool) $data['result']));
5050
$countInvalid = $count - $countValid;
5151

5252
return [

0 commit comments

Comments
 (0)