Skip to content

Commit 6011453

Browse files
authored
Replace StyleCI with PHP CS Fixer (#294)
1 parent 2abf35d commit 6011453

39 files changed

+413
-449
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 & 20 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ phpunit.phar
3636
/node_modules
3737
/package-lock.json
3838
.phpunit.result.cache
39+
40+
# PHP CS Fixer
41+
/.php-cs-fixer.cache
42+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

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

.styleci.yml

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Enh #287: Allow `Dropdown::togglerVariant()` to be `null`, avoiding it setting a variant class (@Mister-42)
66
- Bug #288: Add support for custom togglerClasses in `Dropdown` widget, and `addDropdownClass()` method (@terabytesoftw)
77
- Enh #291: Add `navId()` method to `NavBar` widget (@terabytesoftw)
8+
- Enh #294: Explicitly import classes and functions in "use" section (@mspirkov)
89

910
## 1.0.0 April 13, 2025
1011

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"yiisoft/widget": "^2.0"
2222
},
2323
"require-dev": {
24+
"friendsofphp/php-cs-fixer": "^3.92.5",
2425
"maglnet/composer-require-checker": "^4.1",
2526
"phpunit/phpunit": "^10.5",
2627
"rector/rector": "^2.0",

src/Accordion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ final class Accordion extends Widget
6767

6868
private array $togglerAttributes = [];
6969

70-
private string|null $togglerTag = null;
70+
private ?string $togglerTag = null;
7171

7272
/**
7373
* Adds a sets of attributes.

src/AccordionItem.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ private function __construct(
3737
private bool $encodeHeader,
3838
private string $header,
3939
private bool|string $id,
40-
) {
41-
}
40+
) {}
4241

4342
/**
4443
* Creates a new {@see AccordionItem} instance.
@@ -59,7 +58,7 @@ public static function to(
5958
bool|string $id = true,
6059
bool $encodeHeader = true,
6160
bool $encodeBody = true,
62-
bool $active = false
61+
bool $active = false,
6362
): self {
6463
return new self($active, $body, $encodeBody, $encodeHeader, $header, $id);
6564
}

src/Alert.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ final class Alert extends Widget
4343

4444
private array $closeButtonAttributes = [];
4545

46-
private string|null $closeButtonTag = null;
46+
private ?string $closeButtonTag = null;
4747

4848
private string $closeButtonLabel = '';
4949

5050
private bool $dismissable = false;
5151

5252
private bool $fade = false;
5353

54-
private string|null $header = null;
54+
private ?string $header = null;
5555

5656
private array $headerAttributes = [];
5757

@@ -417,7 +417,7 @@ public function fade(bool $enabled): self
417417
* $alert->header('Header content');
418418
* ```
419419
*/
420-
public function header(string|null $content, bool $encode = true): self
420+
public function header(?string $content, bool $encode = true): self
421421
{
422422
if ($encode) {
423423
$content = Html::encode($content);
@@ -562,7 +562,7 @@ public function render(): string
562562
'{header}' => $this->renderHeader(),
563563
'{body}' => $this->body,
564564
'{toggler}' => $toggler,
565-
]
565+
],
566566
);
567567

568568
$content = preg_replace("/\n{2}/", "\n", $content) ?? '';
@@ -577,7 +577,7 @@ public function render(): string
577577
*
578578
* @psalm-return non-empty-string|null The generated ID.
579579
*/
580-
private function getId(): string|null
580+
private function getId(): ?string
581581
{
582582
return match ($this->id) {
583583
true => $this->attributes['id'] ?? Html::generateId(self::NAME . '-'),

0 commit comments

Comments
 (0)