Skip to content

Commit b2ac131

Browse files
authored
chore: add more php-cs-fixer rules
1 parent 7c64c7c commit b2ac131

File tree

340 files changed

+1140
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+1140
-1112
lines changed

.github/workflows/coding-conventions.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ jobs:
99
name: Run Style Check
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
12+
- uses: actions/checkout@v4
1413

15-
- name: Run PHP-CS-Fixer
16-
uses: docker://oskarstark/php-cs-fixer-ga
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
1716
with:
18-
args: --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -v
17+
php-version: 8.4
18+
coverage: none
19+
20+
- name: Install composer dependencies
21+
uses: ramsey/composer-install@v3
22+
23+
- name: Run php-cs-fixer
24+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -vvv
25+
env:
26+
PHP_CS_FIXER_IGNORE_ENV: true
1927

2028
phpstan:
2129
name: "Run Static Analysis: PHPStan"
@@ -52,4 +60,4 @@ jobs:
5260
uses: ramsey/composer-install@v3
5361

5462
- name: Run Rector
55-
run: vendor/bin/rector process --no-ansi --dry-run --no-progress-bar
63+
run: vendor/bin/rector process --no-ansi --dry-run --no-progress-bar

.github/workflows/quality-assurance.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,24 @@ jobs:
2828
name: Check Styling
2929
runs-on: ubuntu-latest
3030
steps:
31-
- name: Checkout code
32-
uses: actions/checkout@v4
31+
- uses: actions/checkout@v4
3332

34-
- name: Run PHP-CS-Fixer
35-
uses: docker://oskarstark/php-cs-fixer-ga
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
3635
with:
37-
args: --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -v
36+
php-version: 8.3
37+
coverage: none
38+
39+
- name: Install composer dependencies
40+
uses: ramsey/composer-install@v3
41+
42+
- name: Run PHPStan
43+
run: vendor/bin/phpstan --error-format=github
44+
45+
- name: Run PHP-CS-Fixer
46+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -vvv
47+
env:
48+
PHP_CS_FIXER_IGNORE_ENV: true
3849

3950
phpstan:
4051
name: Perform Static Analysis

.php-cs-fixer.dist.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,50 @@
1313
->ignoreVCS(true);
1414

1515
return (new PhpCsFixer\Config())
16+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
1617
->setCacheFile('.cache/fixer/cs-fixer.cache')
1718
->setRules([
1819
'@PSR12' => true,
20+
'@PHP84Migration' => true,
21+
'ordered_attributes' => true,
22+
'ordered_traits' => true,
23+
'attribute_empty_parentheses' => true,
24+
'yoda_style' => [
25+
'equal' => false,
26+
'identical' => false,
27+
'less_and_greater' => false
28+
],
29+
'get_class_to_class_keyword' => true,
30+
'cast_spaces' => true,
31+
'single_space_around_construct' => true,
32+
'heredoc_indentation' => true,
33+
'types_spaces' => true,
34+
'single_quote' => true,
35+
'no_short_bool_cast' => true,
36+
'explicit_string_variable' => true,
37+
'no_extra_blank_lines' => [
38+
'tokens' => [
39+
'case',
40+
'continue',
41+
'curly_brace_block',
42+
'default',
43+
'extra',
44+
'parenthesis_brace_block',
45+
'square_brace_block',
46+
'switch',
47+
'throw',
48+
'use',
49+
],
50+
],
1951
'array_syntax' => ['syntax' => 'short'],
20-
'ordered_imports' => ['sort_algorithm' => 'alpha'],
52+
'ordered_imports' => [
53+
'sort_algorithm' => 'alpha',
54+
'imports_order' => [
55+
'class',
56+
'function',
57+
'const',
58+
],
59+
],
2160
'no_unused_imports' => true,
2261
'no_unneeded_import_alias' => true,
2362
'blank_line_between_import_groups' => false,
@@ -33,7 +72,9 @@
3372
'import_functions' => true,
3473
],
3574
'not_operator_with_successor_space' => true,
36-
'trailing_comma_in_multiline' => true,
75+
'trailing_comma_in_multiline' => [
76+
'elements' => ['arrays', 'arguments', 'parameters', 'match'],
77+
],
3778
'phpdoc_scalar' => true,
3879
'unary_operator_spaces' => true,
3980
'binary_operator_spaces' => true,

src/Tempest/Auth/src/AuthBootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
final readonly class AuthBootstrap
1212
{
1313
public function __construct(
14-
private Router $router
14+
private Router $router,
1515
) {
1616
}
1717

src/Tempest/Auth/src/CurrentUserNotLoggedIn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ final class CurrentUserNotLoggedIn extends Exception
1010
{
1111
public function __construct()
1212
{
13-
parent::__construct("Tried to request the current user, but no one is logged in");
13+
parent::__construct('Tried to request the current user, but no one is logged in');
1414
}
1515
}

src/Tempest/Auth/src/Install/Permission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020

2121
public function matches(string|UnitEnum|self $match): bool
2222
{
23-
$match = match(true) {
23+
$match = match (true) {
2424
is_string($match) => $match,
2525
$match instanceof BackedEnum => $match->value,
2626
$match instanceof UnitEnum => $match->name,

src/Tempest/Auth/src/Install/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use Tempest\Auth\CanAuthorize;
1111
use Tempest\Database\DatabaseModel;
1212
use Tempest\Database\IsDatabaseModel;
13-
use function Tempest\Support\arr;
1413
use UnitEnum;
14+
use function Tempest\Support\arr;
1515

1616
final class User implements DatabaseModel, CanAuthenticate, CanAuthorize
1717
{

src/Tempest/Cache/src/CacheClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __invoke(bool $all = false): void
2525

2626
if ($all === false) {
2727
$caches = $this->ask(
28-
question: "Which caches do you want to clear?",
28+
question: 'Which caches do you want to clear?',
2929
options: $this->cacheConfig->caches,
3030
multiple: true,
3131
);

src/Tempest/Cache/src/CacheConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function __construct(
2929
?bool $enable = null,
3030
) {
3131
$this->enable = $enable ?? env('CACHE') ?? null;
32-
$this->projectCache = (bool)env('PROJECT_CACHE', false);
33-
$this->viewCache = (bool)env('VIEW_CACHE', false);
32+
$this->projectCache = (bool) env('PROJECT_CACHE', false);
33+
$this->viewCache = (bool) env('VIEW_CACHE', false);
3434
$this->discoveryCache = $this->resolveDiscoveryCacheStrategy();
3535
}
3636

src/Tempest/Cache/src/CacheStatusCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __invoke(): void
2929
/** @var Cache $cache */
3030
$cache = $this->container->get($cacheClass);
3131

32-
$reason = match($this->cacheConfig->enable) {
32+
$reason = match ($this->cacheConfig->enable) {
3333
true => ' (global CACHE = true)',
3434
false => ' (global CACHE = false)',
3535
null => '',
@@ -39,7 +39,7 @@ public function __invoke(): void
3939
'<em>%s</em> %s%s',
4040
$cacheClass,
4141
$cache->isEnabled() ? '<style="fg-green">enabled</style>' : '<style="fg-red">disabled</style>',
42-
$reason
42+
$reason,
4343
));
4444
}
4545
}

0 commit comments

Comments
 (0)