Skip to content

Commit 8ef314c

Browse files
authored
style: format and lint using mago (#986)
1 parent ea48c60 commit 8ef314c

File tree

341 files changed

+1449
-1057
lines changed

Some content is hidden

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

341 files changed

+1449
-1057
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
tests/ export-ignore
55
.gitattributes export-ignore
66
.gitignore export-ignore
7-
.php-cs-fixer.dist.php export-ignore
87
monorepo-builder.php export-ignore
98
phpstan.neon.dist export-ignore
109
phpstan-baseline.neon export-ignore

.github/workflows/coding-conventions.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414

15-
# - name: Setup PHP
16-
# uses: shivammathur/setup-php@v2
17-
# with:
18-
# php-version: 8.4
19-
# coverage: none
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.4
19+
coverage: none
2020

21-
# - name: Install composer dependencies
22-
# uses: ramsey/composer-install@v3
21+
- name: Install dependencies
22+
run: |
23+
composer update --prefer-dist --no-interaction
24+
composer mago:install-binary
2325
24-
# - name: Run php-cs-fixer
25-
# run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -vvv
26-
# env:
27-
# PHP_CS_FIXER_IGNORE_ENV: true
26+
- name: Run Mago
27+
run: |
28+
./vendor/bin/mago fmt --dry-run
29+
./vendor/bin/mago lint --reporting-format=github
2830
2931
- name: Setup Bun
3032
uses: oven-sh/setup-bun@v2

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"require-dev": {
4040
"aidan-casey/mock-client": "dev-master",
41-
"friendsofphp/php-cs-fixer": "^3.21",
41+
"carthage-software/mago": "0.19.3",
4242
"guzzlehttp/psr7": "^2.6.1",
4343
"illuminate/view": "~11.7.0",
4444
"mikey179/vfsstream": "^2.0@dev",
@@ -167,10 +167,16 @@
167167
"bin": [
168168
"src/Tempest/Console/bin/tempest"
169169
],
170+
"config": {
171+
"allow-plugins": {
172+
"carthage-software/mago": true
173+
}
174+
},
170175
"scripts": {
171176
"phpunit": "vendor/bin/phpunit --display-warnings --display-skipped --display-deprecations --display-errors --display-notices",
172177
"coverage": "vendor/bin/phpunit --coverage-html build/reports/html --coverage-clover build/reports/clover.xml",
173-
"csfixer": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --allow-risky=yes",
178+
"mago:fmt": "vendor/bin/mago fmt",
179+
"mago:lint": "vendor/bin/mago lint --fix && vendor/bin/mago lint",
174180
"phpstan": "vendor/bin/phpstan analyse src tests --memory-limit=1G",
175181
"rector": "vendor/bin/rector process --no-ansi",
176182
"merge": "php -d\"error_reporting = E_ALL & ~E_DEPRECATED\" vendor/bin/monorepo-builder merge",
@@ -179,11 +185,13 @@
179185
"./bin/release"
180186
],
181187
"qa": [
188+
"composer mago:fmt",
182189
"composer merge",
183190
"./bin/validate-packages",
184191
"./tempest discovery:clear",
185192
"composer rector",
186193
"composer phpunit",
194+
"composer mago:lint",
187195
"composer phpstan"
188196
]
189197
}

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import defineEslintConfig from '@innocenzi/eslint-config'
22

33
export default defineEslintConfig({
4+
toml: {
5+
overrides: {
6+
'toml/array-element-newline': 'off',
7+
},
8+
},
49
ignores: ['.github', 'public', '*.json', '**/composer.json'],
510
})

mago.toml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
php_version = "8.4.0"
2+
3+
[source]
4+
paths = ["src"]
5+
includes = ["vendor"]
6+
excludes = [
7+
"./vendor/symfony/cache/Traits/ValueWrapper.php",
8+
"./vendor/composer",
9+
]
10+
11+
[format]
12+
print_width = 180
13+
tab_width = 4
14+
use_tabs = false
15+
space_after_not_operator = true
16+
null_type_hint = "question"
17+
space_before_arrow_function_params = true
18+
always_break_named_arguments_list = false
19+
preserve_breaking_member_access_chain = true
20+
preserve_breaking_argument_list = true
21+
preserve_breaking_array_like = true
22+
preserve_breaking_parameter_list = true
23+
preserve_breaking_attribute_list = true
24+
preserve_breaking_conditional_expression = true
25+
26+
[linter]
27+
default_plugins = true
28+
plugins = ["symfony", "php-unit"]
29+
30+
# MAINTENABILITY
31+
[[linter.rules]]
32+
name = "maintainability/too-many-enum-cases"
33+
level = "off"
34+
35+
[[linter.rules]]
36+
name = "maintainability/excessive-parameter-list"
37+
level = "off"
38+
39+
[[linter.rules]]
40+
name = "maintainability/halstead"
41+
level = "off"
42+
43+
[[linter.rules]]
44+
name = "maintainability/too-many-methods"
45+
level = "off"
46+
47+
[[linter.rules]]
48+
name = "maintainability/kan-defect"
49+
level = "off"
50+
51+
[[linter.rules]]
52+
name = "maintainability/cyclomatic-complexity"
53+
level = "off"
54+
55+
# STRICTNESS
56+
[[linter.rules]]
57+
name = "strictness/require-return-type"
58+
ignore_arrow_function = true
59+
ignore_closure = true
60+
61+
# https://github.com/carthage-software/mago/issues/146
62+
# [[linter.rules]]
63+
# name = "strictness/require-strict-types"
64+
# level = "off"
65+
66+
[[linter.rules]]
67+
name = "strictness/require-parameter-type"
68+
ignore_arrow_function = true
69+
ignore_closure = true
70+
71+
[[linter.rules]]
72+
name = "strictness/no-shorthand-ternary"
73+
level = "off"
74+
75+
[[linter.rules]]
76+
name = "strictness/no-assignment-in-condition"
77+
level = "off"
78+
79+
# BEST PRACTICES
80+
[[linter.rules]]
81+
name = "best-practices/no-else-clause"
82+
level = "off"
83+
84+
[[linter.rules]]
85+
name = "best-practices/no-boolean-literal-comparison"
86+
level = "off"
87+
88+
[[linter.rules]]
89+
name = "best-practices/no-boolean-flag-parameter"
90+
level = "off"
91+
92+
# SAFETY
93+
[[linter.rules]]
94+
name = "safety/no-error-control-operator"
95+
level = "off"
96+
97+
# PHPUNIT
98+
[[linter.rules]]
99+
name = "php-unit/assertions-style"
100+
style = "this"
101+
102+
[[linter.rules]]
103+
name = "php-unit/strict-assertions"
104+
level = "off"
105+
106+
# NAMING
107+
[[linter.rules]]
108+
name = "naming/interface"
109+
psr = false
110+
111+
[[linter.rules]]
112+
name = "naming/trait"
113+
psr = false
114+
115+
[[linter.rules]]
116+
name = "naming/class"
117+
psr = false
118+
119+
# HELP
120+
[[linter.rules]]
121+
name = "redundancy/redundant-file"
122+
level = "off"
123+
124+
# CONSIDER ENABLING
125+
[[linter.rules]]
126+
name = "analysis/override-attribute"
127+
level = "off"
128+
129+
[[linter.rules]]
130+
name = "comment/no-untagged-todo"
131+
level = "off"

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ parameters:
3636
message: '#.*undefined property Dom*#'
3737
-
3838
message: '#.*undefined method Dom*#'
39+
-
40+
message: '#File ends with a trailing whitespace*#'
41+
path: src/Tempest/View/src/Stubs/view.stub.php
3942

4043
disallowedFunctionCalls:
4144
-

rector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
66
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
77
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
8+
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
89
use Rector\Config\RectorConfig;
910
use Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector;
1011
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
@@ -57,7 +58,7 @@
5758
EncapsedStringsToSprintfRector::class,
5859
AddArrowFunctionReturnTypeRector::class,
5960
])
60-
->withSkipPath(__DIR__ .'/src/Tempest/Router/src/Exceptions/HttpProductionErrorHandler.php')
61+
->withSkipPath(__DIR__ . '/src/Tempest/Router/src/Exceptions/HttpProductionErrorHandler.php')
6162
->withSkipPath(__DIR__ . '/src/Tempest/Router/src/Exceptions/exception.php')
6263
->withParallel(300, 10, 10)
6364
->withPreparedSets(

src/Tempest/Auth/src/AuthInstaller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Tempest\Core\Installer;
88
use Tempest\Core\PublishesFiles;
9+
910
use function Tempest\src_path;
1011

1112
final class AuthInstaller implements Installer

src/Tempest/Auth/src/AuthorizerMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __invoke(Request $request, HttpMiddlewareCallable $next): Respon
3434

3535
$user = $this->authenticator->currentUser();
3636

37-
if (! $user instanceof CanAuthorize) {
37+
if (! ($user instanceof CanAuthorize)) {
3838
return new Forbidden();
3939
}
4040

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Tempest\Database\DatabaseModel;
1212
use Tempest\Database\IsDatabaseModel;
1313
use UnitEnum;
14+
1415
use function Tempest\Support\arr;
1516

1617
final class User implements DatabaseModel, CanAuthenticate, CanAuthorize

0 commit comments

Comments
 (0)