Skip to content

Commit 40690be

Browse files
authored
Replace StyleCI with PHP CS Fixer (#106)
1 parent d94ef0a commit 40690be

25 files changed

+155
-191
lines changed

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

.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
@@ -29,3 +29,7 @@ phpunit.phar
2929
/phpunit.xml
3030
# phpunit cache
3131
/.phpunit.cache
32+
33+
# PHP CS Fixer
34+
/.php-cs-fixer.cache
35+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
]);
14+
15+
return (new Config())
16+
->setRiskyAllowed(true)
17+
->setParallelConfig(ParallelConfigFactory::detect())
18+
->setRules([
19+
'@PER-CS3.0' => true,
20+
'no_unused_imports' => true,
21+
'ordered_class_elements' => true,
22+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
23+
'declare_strict_types' => true,
24+
'native_function_invocation' => true,
25+
'native_constant_invocation' => true,
26+
'fully_qualified_strict_types' => [
27+
'import_symbols' => true
28+
],
29+
'global_namespace_import' => [
30+
'import_classes' => true,
31+
'import_constants' => true,
32+
'import_functions' => true,
33+
],
34+
])
35+
->setFinder($finder);

.styleci.yml

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

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 2.1.3 under development
44

5-
- no changes in this release.
5+
- Enh #106: Explicitly import classes, functions, and constants in "use" section (@mspirkov)
66

77
## 2.1.2 December 18, 2025
88

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"yiisoft/strings": "^2.0"
4040
},
4141
"require-dev": {
42+
"friendsofphp/php-cs-fixer": "^3.92.5",
4243
"httpsoft/http-message": "^1.1.6",
4344
"maglnet/composer-require-checker": "^4.7.1",
4445
"phpunit/phpunit": "^10.5.52",

src/DataResponse.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Psr\Http\Message\StreamFactoryInterface;
1010
use Psr\Http\Message\StreamInterface;
1111
use RuntimeException;
12+
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
1213

1314
use function ftruncate;
1415
use function is_callable;
@@ -22,7 +23,7 @@
2223
* A wrapper around PSR-7 response that is assigned raw data to be formatted with a formatter later.
2324
*
2425
* For example, `['name' => 'Dmitriy']` to be formatted as JSON using
25-
* {@see \Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter} when {@see DataResponse::getBody()} is called.
26+
* {@see JsonDataResponseFormatter} when {@see DataResponse::getBody()} is called.
2627
*/
2728
final class DataResponse implements ResponseInterface
2829
{
@@ -49,7 +50,7 @@ public function __construct(
4950
int $code,
5051
string $reasonPhrase,
5152
ResponseFactoryInterface $responseFactory,
52-
StreamFactoryInterface $streamFactory
53+
StreamFactoryInterface $streamFactory,
5354
) {
5455
$this->createResponse($code, $reasonPhrase, $responseFactory, $streamFactory);
5556
}
@@ -313,7 +314,7 @@ private function createResponse(
313314
int $code,
314315
string $reasonPhrase,
315316
ResponseFactoryInterface $responseFactory,
316-
StreamFactoryInterface $streamFactory
317+
StreamFactoryInterface $streamFactory,
317318
): void {
318319
$response = $responseFactory->createResponse($code, $reasonPhrase);
319320
$stream = $response->getBody();

src/DataResponseFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ final class DataResponseFactory implements DataResponseFactoryInterface
1616
public function __construct(
1717
private ResponseFactoryInterface $responseFactory,
1818
private StreamFactoryInterface $streamFactory,
19-
) {
20-
}
19+
) {}
2120

2221
public function createResponse($data = null, int $code = Status::OK, string $reasonPhrase = ''): DataResponse
2322
{

src/Formatter/HtmlDataResponseFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function format(DataResponse $dataResponse): ResponseInterface
4040
sprintf(
4141
'Data must be either a scalar value, null, or a stringable object. %s given.',
4242
get_debug_type($data),
43-
)
43+
),
4444
);
4545
}
4646

0 commit comments

Comments
 (0)