Skip to content

Commit e66b765

Browse files
committed
Improve codestyle rules
1 parent 63c9566 commit e66b765

19 files changed

+252
-35
lines changed

Diff for: .php-cs-fixer.php

+223
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,232 @@
88
'@PER-CS2.0' => true,
99
'@PER-CS2.0:risky' => true,
1010
'strict_param' => true,
11+
'align_multiline_comment' => true,
1112
'array_syntax' => [
1213
'syntax' => 'short',
1314
],
15+
'backtick_to_shell_exec' => true,
16+
'binary_operator_spaces' => true,
17+
'blank_line_before_statement' => [
18+
'statements' => [
19+
'return',
20+
],
21+
],
22+
'braces_position' => [
23+
'allow_single_line_anonymous_functions' => true,
24+
'allow_single_line_empty_anonymous_classes' => true,
25+
],
26+
'class_attributes_separation' => [
27+
'elements' => [
28+
'method' => 'one',
29+
],
30+
],
31+
'class_reference_name_casing' => true,
32+
'clean_namespace' => true,
33+
'declare_parentheses' => true,
34+
'echo_tag_syntax' => true,
35+
'empty_loop_body' => ['style' => 'braces'],
36+
'empty_loop_condition' => true,
37+
'fully_qualified_strict_types' => true,
38+
'general_phpdoc_tag_rename' => [
39+
'replacements' => [
40+
'inheritDocs' => 'inheritDoc',
41+
],
42+
],
43+
'global_namespace_import' => [
44+
'import_classes' => false,
45+
'import_constants' => false,
46+
'import_functions' => false,
47+
],
48+
'include' => true,
49+
'increment_style' => true,
50+
'integer_literal_case' => true,
51+
'lambda_not_used_import' => true,
52+
'linebreak_after_opening_tag' => true,
53+
'magic_constant_casing' => true,
54+
'magic_method_casing' => true,
55+
'native_function_casing' => true,
56+
'native_type_declaration_casing' => true,
57+
'no_alias_language_construct_call' => true,
58+
'no_alternative_syntax' => true,
59+
'no_binary_string' => true,
60+
'no_blank_lines_after_phpdoc' => true,
61+
'no_empty_comment' => true,
62+
'no_empty_phpdoc' => true,
63+
'no_empty_statement' => true,
64+
'no_extra_blank_lines' => [
65+
'tokens' => [
66+
'attribute',
67+
'case',
68+
'continue',
69+
'curly_brace_block',
70+
'default',
71+
'extra',
72+
'parenthesis_brace_block',
73+
'square_brace_block',
74+
'switch',
75+
'throw',
76+
'use',
77+
],
78+
],
79+
'no_leading_namespace_whitespace' => true,
80+
'no_mixed_echo_print' => true,
81+
'no_null_property_initialization' => true,
82+
'no_short_bool_cast' => true,
83+
'no_singleline_whitespace_before_semicolons' => true,
84+
'no_spaces_around_offset' => true,
85+
'no_superfluous_phpdoc_tags' => [
86+
'allow_hidden_params' => true,
87+
'remove_inheritdoc' => true,
88+
],
89+
'no_trailing_comma_in_singleline' => true,
90+
'no_unneeded_braces' => [
91+
'namespaces' => true,
92+
],
93+
'no_unneeded_control_parentheses' => [
94+
'statements' => [
95+
'break',
96+
'clone',
97+
'continue',
98+
'echo_print',
99+
'others',
100+
'return',
101+
'switch_case',
102+
'yield',
103+
'yield_from',
104+
],
105+
],
106+
'no_unneeded_import_alias' => true,
107+
'no_unset_cast' => true,
108+
'no_unused_imports' => true,
109+
'no_useless_concat_operator' => true,
110+
'no_useless_nullsafe_operator' => true,
111+
'no_whitespace_before_comma_in_array' => true,
112+
'normalize_index_brace' => true,
113+
'nullable_type_declaration' => true,
114+
'nullable_type_declaration_for_default_null_value' => true,
115+
'object_operator_without_whitespace' => true,
116+
'operator_linebreak' => [
117+
'only_booleans' => true,
118+
],
119+
'ordered_imports' => [
120+
'imports_order' => [
121+
'class',
122+
'function',
123+
'const',
124+
],
125+
'sort_algorithm' => 'alpha',
126+
],
127+
'ordered_types' => [
128+
'null_adjustment' => 'always_last',
129+
'sort_algorithm' => 'none',
130+
],
131+
'php_unit_fqcn_annotation' => true,
132+
'php_unit_method_casing' => true,
133+
'phpdoc_align' => false,
134+
'phpdoc_annotation_without_dot' => true,
135+
'phpdoc_indent' => true,
136+
'phpdoc_inline_tag_normalizer' => true,
137+
'phpdoc_no_access' => true,
138+
'phpdoc_no_alias_tag' => false,
139+
'phpdoc_no_package' => true,
140+
'phpdoc_no_useless_inheritdoc' => true,
141+
'phpdoc_order' => [
142+
'order' => [
143+
'internal',
144+
'psalm-internal',
145+
'template',
146+
'template-extends',
147+
'extends',
148+
'template-implements',
149+
'implements',
150+
'property',
151+
'property-read',
152+
'property-write',
153+
'psalm-require-implements',
154+
'phpstan-require-implements',
155+
'psalm-require-extends',
156+
'phpstan-require-extends',
157+
'mixin',
158+
'readonly',
159+
'psalm-readonly',
160+
'phpstan-readonly',
161+
'param',
162+
'return',
163+
'throws',
164+
'api',
165+
'psalm-suppress',
166+
],
167+
],
168+
'phpdoc_return_self_reference' => true,
169+
'phpdoc_scalar' => true,
170+
'phpdoc_separation' => [
171+
'groups' => [
172+
[
173+
'property',
174+
'property-read',
175+
'property-write',
176+
],
177+
['internal', 'psalm-internal', 'phpstan-internal'],
178+
[
179+
'template',
180+
'template-extends',
181+
'extends',
182+
'template-implements',
183+
'implements',
184+
'psalm-require-implements',
185+
'phpstan-require-implements',
186+
'psalm-require-extends',
187+
'phpstan-require-extends',
188+
],
189+
['psalm-taint-sink', 'param'],
190+
['return', 'throws', 'api'],
191+
['psalm-suppress'],
192+
],
193+
],
194+
'phpdoc_single_line_var_spacing' => true,
195+
'phpdoc_tag_type' => [
196+
'tags' => [
197+
'inheritDoc' => 'inline',
198+
],
199+
],
200+
'phpdoc_to_comment' => false,
201+
'phpdoc_trim' => true,
202+
'phpdoc_trim_consecutive_blank_line_separation' => true,
203+
'phpdoc_types' => true,
204+
'phpdoc_types_order' => [
205+
'null_adjustment' => 'always_last',
206+
'sort_algorithm' => 'none',
207+
],
208+
'phpdoc_var_without_name' => true,
209+
'semicolon_after_instruction' => true,
210+
'simple_to_complex_string_variable' => true,
211+
'single_class_element_per_statement' => true,
212+
'single_import_per_statement' => true,
213+
'single_line_comment_spacing' => true,
214+
'single_line_comment_style' => [
215+
'comment_types' => [
216+
'hash',
217+
],
218+
],
219+
'single_line_throw' => false,
220+
'single_quote' => true,
221+
'space_after_semicolon' => [
222+
'remove_in_empty_for_expressions' => true,
223+
],
224+
'standardize_increment' => true,
225+
'standardize_not_equals' => true,
226+
'statement_indentation' => [
227+
'stick_comment_to_next_continuous_control_statement' => true,
228+
],
229+
'switch_continue_to_break' => true,
230+
'trailing_comma_in_multiline' => true,
231+
'trim_array_spaces' => true,
232+
'type_declaration_spaces' => true,
233+
'types_spaces' => true,
234+
'unary_operator_spaces' => true,
235+
'whitespace_after_comma_in_array' => true,
236+
'yoda_style' => false,
14237
])
15238
->setCacheFile(__DIR__ . '/vendor/.cache.php-cs-fixer')
16239
->setFinder($files);

Diff for: src/DocBlock.php

-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public function offsetGet(mixed $offset): ?TagInterface
7272
}
7373

7474
/**
75-
* {@inheritDoc}
76-
*
7775
* @throws \BadMethodCallException
7876
*/
7977
public function offsetSet(mixed $offset, mixed $value): void
@@ -82,8 +80,6 @@ public function offsetSet(mixed $offset, mixed $value): void
8280
}
8381

8482
/**
85-
* {@inheritDoc}
86-
*
8783
* @throws \BadMethodCallException
8884
*/
8985
public function offsetUnset(mixed $offset): void

Diff for: src/Exception/InvalidTagException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function fromCreatingTag(
2020
string $tag,
2121
string $source,
2222
int $offset = 0,
23-
\Throwable $prev = null,
23+
?\Throwable $prev = null,
2424
): static {
2525
$message = \sprintf('Error while parsing tag @%s', $tag);
2626

Diff for: src/Exception/ParsingException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ParsingException extends \RuntimeException implements RuntimeExceptionInte
1616
final public function __construct(
1717
public readonly string $source,
1818
public readonly int $offset = 0,
19-
string $message = "",
19+
string $message = '',
2020
int $code = 0,
2121
?\Throwable $previous = null,
2222
) {

Diff for: src/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function parse(#[Language('PHP')] string $docblock): DocBlock
4444
try {
4545
/**
4646
* @var Segment $segment
47+
*
4748
* @psalm-suppress InvalidIterator
4849
*/
4950
foreach ($result = $this->analyze($docblock) as $segment) {
@@ -67,7 +68,6 @@ public function parse(#[Language('PHP')] string $docblock): DocBlock
6768

6869
/**
6970
* @return \Generator<array-key, Segment, void, DocBlock>
70-
*
7171
* @throws RuntimeExceptionInterface
7272
*/
7373
private function analyze(string $docblock): \Generator

Diff for: src/Parser/SourceMap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace TypeLang\PHPDoc\Parser;
66

77
/**
8-
* @internal This is an internal library class, please do not use it in your code.
8+
* @internal this is an internal library class, please do not use it in your code
99
* @psalm-internal TypeLang\PHPDoc
1010
*/
1111
final class SourceMap

Diff for: src/Parser/Tag/RegexTagParser.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use TypeLang\PHPDoc\Exception\InvalidTagNameException;
88
use TypeLang\PHPDoc\Exception\RuntimeExceptionInterface;
99
use TypeLang\PHPDoc\Parser\Description\DescriptionParserInterface;
10-
use TypeLang\PHPDoc\Tag\Factory\FactoryInterface;
1110
use TypeLang\PHPDoc\Tag\Content;
11+
use TypeLang\PHPDoc\Tag\Factory\FactoryInterface;
1212
use TypeLang\PHPDoc\Tag\Factory\TagFactory;
1313
use TypeLang\PHPDoc\Tag\InvalidTag;
1414
use TypeLang\PHPDoc\Tag\TagInterface;
@@ -37,6 +37,7 @@ public function __construct(
3737
* - etc...
3838
*
3939
* @phpstan-pure
40+
*
4041
* @psalm-pure
4142
*
4243
* @throws InvalidTagNameException

Diff for: src/ParserInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
interface ParserInterface
1010
{
1111
/**
12-
* @param string $docblock A string containing the DocBlock to parse.
12+
* @param string $docblock a string containing the DocBlock to parse
1313
*/
1414
public function parse(#[Language('PHP')] string $docblock): DocBlock;
1515
}

0 commit comments

Comments
 (0)