Skip to content

Commit 6c8e2f1

Browse files
committed
style: apply php-cs-fixer
1 parent 7fcc3b7 commit 6c8e2f1

19 files changed

Lines changed: 87 additions & 443 deletions

.php-cs-fixer-custom.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
->ignoreUnreadableDirs(false)
121121
->ignoreVCS(true)
122122
->ignoreVCSIgnored(true)
123+
/** @see \Symfony\Component\Finder\Iterator\SortableIterator::__construct() */
124+
// ->sortByExtension()
125+
->sort(static fn (SplFileInfo $a, SplFileInfo $b): int => strnatcmp($a->getExtension(), $b->getExtension()))
123126
)
124127
->setCacheFile(\sprintf('%s/.build/php-cs-fixer/%s.cache', __DIR__, pathinfo(__FILE__, \PATHINFO_FILENAME)))
125128
// ->setParallelConfig(ParallelConfigFactory::sequential())

.php-cs-fixer.dist.php

Lines changed: 5 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* @see https://github.com/guanguans/laravel-soar
1212
*/
1313

14-
use AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer;
1514
use Ergebnis\License\Holder;
1615
use Ergebnis\License\Range;
1716
use Ergebnis\License\Type\MIT;
@@ -22,17 +21,9 @@
2221
use Ergebnis\PhpCsFixer\Config\Rules;
2322
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81;
2423
use PhpCsFixer\Finder;
25-
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
26-
use PhpCsFixer\Fixer\FixerInterface;
2724

2825
require __DIR__.'/vendor/autoload.php';
2926

30-
// putenv('PHP_CS_FIXER_ENFORCE_CACHE=1');
31-
// putenv('PHP_CS_FIXER_IGNORE_ENV=1');
32-
putenv('PHP_CS_FIXER_FUTURE_MODE=1');
33-
putenv('PHP_CS_FIXER_NON_MONOLITHIC=1');
34-
putenv('PHP_CS_FIXER_PARALLEL=1');
35-
3627
return Factory::fromRuleSet(Php81::create()
3728
->withHeader(
3829
(static function (): string {
@@ -51,299 +42,18 @@
5142
return $mit->header();
5243
})()
5344
)
54-
->withCustomFixers(Fixers::fromFixers($forceFQCNFixer = new ForceFQCNFixer))
55-
->withRules(Rules::fromArray([
56-
$forceFQCNFixer->getName() => true,
57-
]))
58-
->withCustomFixers(Fixers::fromFixers(...$erickSkrauchFixers = array_filter(
59-
iterator_to_array(new ErickSkrauch\PhpCsFixer\Fixers),
60-
static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface
61-
&& !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray())
62-
&& !\in_array(
63-
$fixer->getName(),
64-
[
65-
'ErickSkrauch/align_multiline_parameters',
66-
'ErickSkrauch/blank_line_around_class_body',
67-
],
68-
true
69-
)
70-
)))
71-
->withRules(Rules::fromArray(array_reduce(
72-
$erickSkrauchFixers,
73-
static function (array $carry, FixerInterface $fixer): array {
74-
$carry[$fixer->getName()] = true;
75-
76-
return $carry;
77-
},
78-
[]
79-
)))
80-
->withCustomFixers(Fixers::fromFixers(...$phpCsFixerCustomFixers = array_filter(
81-
iterator_to_array(new PhpCsFixerCustomFixers\Fixers),
82-
static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface
83-
&& !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray())
84-
&& !\in_array(
85-
$fixer->getName(),
86-
[
87-
'PhpCsFixerCustomFixers/comment_surrounded_by_spaces',
88-
'PhpCsFixerCustomFixers/declare_after_opening_tag',
89-
'PhpCsFixerCustomFixers/isset_to_array_key_exists',
90-
'PhpCsFixerCustomFixers/no_commented_out_code',
91-
// 'PhpCsFixerCustomFixers/no_leading_slash_in_global_namespace',
92-
'PhpCsFixerCustomFixers/no_nullable_boolean_type',
93-
'PhpCsFixerCustomFixers/phpdoc_only_allowed_annotations',
94-
'PhpCsFixerCustomFixers/typed_class_constant', // @since 8.3
95-
],
96-
true
97-
)
98-
)))
99-
->withRules(Rules::fromArray(array_reduce(
100-
$phpCsFixerCustomFixers,
101-
static function (array $carry, FixerInterface $fixer): array {
102-
$carry[$fixer->getName()] = true;
103-
104-
return $carry;
105-
},
106-
[]
107-
)))
108-
->withRules(Rules::fromArray([
109-
// '@auto' => true,
110-
// '@auto:risky' => true,
111-
// '@autoPHPMigration' => true,
112-
// '@autoPHPMigration:risky' => true,
113-
// '@autoPHPUnitMigration:risky' => true,
114-
// '@DoctrineAnnotation' => true,
115-
// '@PHP7x4Migration' => true,
116-
// '@PHP7x4Migration:risky' => true,
117-
// '@PHP8x0Migration' => true,
118-
// '@PHP8x0Migration:risky' => true,
119-
'@PHP8x1Migration' => true,
120-
// '@PHP8x1Migration:risky' => true,
121-
// '@PHP8x2Migration' => true,
122-
// '@PHP8x2Migration:risky' => true,
123-
// '@PHP8x3Migration' => true,
124-
// '@PHP8x3Migration:risky' => true,
125-
// '@PHP8x4Migration' => true,
126-
// '@PHP8x4Migration:risky' => true,
127-
// '@PHP8x5Migration' => true,
128-
// '@PHP8x5Migration:risky' => true,
129-
// '@PhpCsFixer' => true,
130-
// '@PhpCsFixer:risky' => true,
131-
// '@PHPUnit8x4Migration:risky' => true,
132-
// '@PHPUnit9x1Migration:risky' => true,
133-
'@PHPUnit10x0Migration:risky' => true,
134-
]))
45+
->withCustomFixers(Fixers::fromFixers(... require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/custom-fixers.php'))
46+
->withRules(Rules::fromArray(require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/custom-rules.php'))
47+
->withRules(Rules::fromArray(require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/rules.php'))
13548
->withRules(Rules::fromArray([
136-
'align_multiline_comment' => [
137-
'comment_type' => 'phpdocs_only',
138-
],
139-
'attribute_empty_parentheses' => [
140-
'use_parentheses' => false,
141-
],
142-
'blank_line_before_statement' => [
143-
'statements' => [
144-
'break',
145-
// 'case',
146-
'continue',
147-
'declare',
148-
// 'default',
149-
'do',
150-
'exit',
151-
'for',
152-
'foreach',
153-
'goto',
154-
'if',
155-
'include',
156-
'include_once',
157-
'phpdoc',
158-
'require',
159-
'require_once',
160-
'return',
161-
'switch',
162-
'throw',
163-
'try',
164-
'while',
165-
'yield',
166-
'yield_from',
167-
],
168-
],
169-
'class_definition' => [
170-
'inline_constructor_arguments' => false,
171-
'multi_line_extends_each_single_line' => false,
172-
'single_item_single_line' => false,
173-
'single_line' => false,
174-
'space_before_parenthesis' => false,
175-
],
176-
'concat_space' => [
177-
'spacing' => 'none',
178-
],
179-
'empty_loop_condition' => [
180-
'style' => 'for',
181-
],
182-
'explicit_string_variable' => false,
183-
'final_class' => false,
184-
// 'final_internal_class' => false,
49+
'@autoPHPUnitMigration:risky' => true,
50+
'PhpCsFixerCustomFixers/comment_surrounded_by_spaces' => false,
18551
'final_public_method_for_abstract_class' => false,
186-
'fully_qualified_strict_types' => [
187-
'import_symbols' => false,
188-
'leading_backslash_in_global_namespace' => false,
189-
'phpdoc_tags' => [
190-
// 'param',
191-
// 'phpstan-param',
192-
// 'phpstan-property',
193-
// 'phpstan-property-read',
194-
// 'phpstan-property-write',
195-
// 'phpstan-return',
196-
// 'phpstan-var',
197-
// 'property',
198-
// 'property-read',
199-
// 'property-write',
200-
// 'psalm-param',
201-
// 'psalm-property',
202-
// 'psalm-property-read',
203-
// 'psalm-property-write',
204-
// 'psalm-return',
205-
// 'psalm-var',
206-
// 'return',
207-
// 'see',
208-
// 'throws',
209-
// 'var',
210-
],
211-
],
212-
'logical_operators' => false,
213-
'mb_str_functions' => false,
214-
'native_function_invocation' => [
215-
'exclude' => [],
216-
'include' => ['@compiler_optimized', 'is_scalar'],
217-
'scope' => 'all',
218-
'strict' => true,
219-
],
220-
'new_with_parentheses' => [
221-
'anonymous_class' => false,
222-
'named_class' => false,
223-
],
224-
'no_extra_blank_lines' => [
225-
'tokens' => [
226-
'attribute',
227-
'break',
228-
'case',
229-
// 'comma',
230-
'continue',
231-
'curly_brace_block',
232-
'default',
233-
'extra',
234-
'parenthesis_brace_block',
235-
'return',
236-
'square_brace_block',
237-
'switch',
238-
'throw',
239-
'use',
240-
],
241-
],
242-
'ordered_traits' => [
243-
'case_sensitive' => true,
244-
],
245-
'php_unit_data_provider_name' => [
246-
'prefix' => 'provide',
247-
'suffix' => 'Cases',
248-
],
249-
'phpdoc_align' => [
250-
'align' => 'left',
251-
'spacing' => 1,
252-
'tags' => [
253-
'method',
254-
'param',
255-
'property',
256-
'property-read',
257-
'property-write',
258-
'return',
259-
'throws',
260-
'type',
261-
'var',
262-
],
263-
],
264-
'phpdoc_line_span' => [
265-
'const' => 'single',
266-
'method' => 'multi',
267-
'property' => 'single',
268-
],
269-
'phpdoc_no_alias_tag' => [
270-
'replacements' => [
271-
'link' => 'see',
272-
// 'property-read' => 'property',
273-
// 'property-write' => 'property',
274-
'type' => 'var',
275-
],
276-
],
277-
'phpdoc_order' => [
278-
'order' => [
279-
'noinspection',
280-
'phan-suppress',
281-
'phpcsSuppress',
282-
'phpstan-ignore',
283-
'psalm-suppress',
284-
285-
'deprecated',
286-
'internal',
287-
'covers',
288-
'uses',
289-
'dataProvider',
290-
'param',
291-
'throws',
292-
'return',
293-
],
294-
],
295-
'phpdoc_order_by_value' => [
296-
'annotations' => [
297-
'author',
298-
'covers',
299-
'coversNothing',
300-
'dataProvider',
301-
'depends',
302-
'group',
303-
'internal',
304-
// 'method',
305-
'mixin',
306-
'property',
307-
'property-read',
308-
'property-write',
309-
'requires',
310-
'throws',
311-
'uses',
312-
],
313-
],
314-
'phpdoc_to_param_type' => [
315-
'scalar_types' => true,
316-
'types_map' => [],
317-
'union_types' => true,
318-
],
319-
'phpdoc_to_property_type' => [
320-
'scalar_types' => true,
321-
'types_map' => [],
322-
'union_types' => true,
323-
],
324-
'phpdoc_to_return_type' => [
325-
'scalar_types' => true,
326-
'types_map' => [],
327-
'union_types' => true,
328-
],
329-
'simplified_if_return' => true,
330-
'simplified_null_return' => true,
331-
'single_line_empty_body' => true,
332-
'statement_indentation' => [
333-
'stick_comment_to_next_continuous_control_statement' => true,
334-
],
335-
'static_lambda' => false, // pest
336-
'static_private_method' => false,
33752
])))
33853
->setUsingCache(true)
33954
->setCacheFile(\sprintf('%s/.build/php-cs-fixer/%s.cache', __DIR__, pathinfo(__FILE__, \PATHINFO_FILENAME)))
34055
->setUnsupportedPhpVersionAllowed(true)
34156
->setFinder(
342-
/**
343-
* @see https://github.com/laravel/pint/blob/main/app/Commands/DefaultCommand.php
344-
* @see https://github.com/laravel/pint/blob/main/app/Factories/ConfigurationFactory.php
345-
* @see https://github.com/laravel/pint/blob/main/app/Repositories/ConfigurationJsonRepository.php
346-
*/
34757
Finder::create()
34858
->in(__DIR__)
34959
->exclude([

.zhlintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"caseIgnores": [
77
":+1:",
88
":bangbang:",
9+
":camera_flash:",
910
":cn:",
1011
":eyes:",
1112
":heart:",
1213
":heavy_exclamation_mark:",
1314
":mail:",
15+
":monocle_face:",
1416
":no_entry_sign:",
1517
":smile:",
1618
":tada:",

_ide_helper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class Soar extends Guanguans\LaravelSoar\Facades\Soar {}
2121
* @method self dumpSoarScore(int $depth = 512, int $options = 0)
2222
* @method array toSoarScore(int $depth = 512, int $options = 0)
2323
*
24-
* @mixin \Illuminate\Database\Eloquent\Builder
25-
*
2624
* @see \Guanguans\LaravelSoar\Mixins\QueryBuilderMixin
2725
* @see \Illuminate\Database\Query\Builder
26+
*
27+
* @mixin \Illuminate\Database\Eloquent\Builder
2828
*/
2929
class Builder {}
3030
}
@@ -35,10 +35,10 @@ class Builder {}
3535
* @method self dumpSoarScore(int $depth = 512, int $options = 0)
3636
* @method array toSoarScore(int $depth = 512, int $options = 0)
3737
*
38-
* @mixin \Illuminate\Database\Query\Builder
39-
*
4038
* @see \Guanguans\LaravelSoar\Mixins\QueryBuilderMixin
4139
* @see \Illuminate\Database\Eloquent\Builder
40+
*
41+
* @mixin \Illuminate\Database\Query\Builder
4242
*/
4343
class Builder {}
4444
}
@@ -49,10 +49,10 @@ class Builder {}
4949
* @method self dumpSoarScore(int $depth = 512, int $options = 0)
5050
* @method array toSoarScore(int $depth = 512, int $options = 0)
5151
*
52-
* @mixin \Illuminate\Database\Eloquent\Builder
53-
*
5452
* @see \Guanguans\LaravelSoar\Mixins\QueryBuilderMixin
5553
* @see \Illuminate\Database\Eloquent\Relations\Relation
54+
*
55+
* @mixin \Illuminate\Database\Eloquent\Builder
5656
*/
5757
class Relation {}
5858
}

0 commit comments

Comments
 (0)