Skip to content

Commit f61265f

Browse files
committed
php-cs-fixer cleanup
1 parent fc75cc1 commit f61265f

File tree

6 files changed

+48
-49
lines changed

6 files changed

+48
-49
lines changed

.php_cs renamed to .php-cs-fixer.dist.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
->name('*.php');
77

88

9-
return PhpCsFixer\Config::create()
9+
return (new PhpCsFixer\Config)
1010
->setUsingCache(true)
1111
->setIndent("\t")
1212
->setLineEnding("\n")
1313
//->setUsingLinter(false)
1414
->setRiskyAllowed(true)
1515
->setRules(
1616
[
17-
'@PHPUnit60Migration:risky' => true,
17+
'@PHPUnit84Migration:risky' => true,
1818
'php_unit_test_case_static_method_calls' => [
1919
'call_type' => 'this',
2020
],
2121

22-
'concat_space' => [
22+
'concat_space' => [
2323
'spacing' => 'one',
2424
],
2525

@@ -36,7 +36,10 @@
3636
'no_leading_import_slash' => true,
3737
'no_leading_namespace_whitespace' => true,
3838

39+
'array_indentation' => true,
40+
3941
'no_whitespace_in_blank_line' => true,
42+
'no_trailing_whitespace' => true,
4043

4144
'phpdoc_add_missing_param_annotation' => [ 'only_untyped' => true, ],
4245
'phpdoc_indent' => true,
@@ -84,6 +87,7 @@
8487

8588
'single_line_after_imports' => true,
8689
'single_blank_line_before_namespace' => true,
90+
'single_line_comment_spacing' => true,
8791
'blank_line_after_namespace' => true,
8892
'single_blank_line_at_eof' => true,
8993
'ternary_to_null_coalescing' => true,
@@ -102,11 +106,11 @@
102106
],
103107

104108
'blank_line_before_statement' => [
105-
'statements' => [ 'continue', 'try', 'switch', 'die', 'exit', 'throw', 'return', 'yield', 'do' ],
109+
'statements' => [ 'continue', 'try', 'switch', 'exit', 'throw', 'return', 'yield', 'do' ],
106110
],
107111

108112
'no_superfluous_phpdoc_tags' => [
109-
'remove_inheritdoc' => false, // specifically for this, for now
113+
'remove_inheritdoc' => true,
110114
],
111115
'no_superfluous_elseif' => true,
112116

@@ -118,6 +122,7 @@
118122
'escape_implicit_backslashes' => true,
119123
'explicit_indirect_variable' => true,
120124
'heredoc_to_nowdoc' => true,
125+
'heredoc_indentation' => true,
121126

122127

123128
'no_singleline_whitespace_before_semicolons' => true,
@@ -148,6 +153,26 @@
148153
'elseif' => true,
149154

150155
'simple_to_complex_string_variable' => true,
156+
157+
'global_namespace_import' => [
158+
'import_classes' => false,
159+
'import_constants' => false,
160+
'import_functions' => false,
161+
],
162+
163+
'trailing_comma_in_multiline' => true,
164+
'single_line_comment_style' => true,
165+
166+
'is_null' => true,
167+
'yoda_style' => [
168+
'equal' => false,
169+
'identical' => false,
170+
'less_and_greater' => null,
171+
],
172+
173+
'empty_loop_condition' => [
174+
'style' => 'for',
175+
],
151176
]
152177
)
153178
->setFinder($finder);

src/Corpus/Sniffs/ControlStructures/ClosingBraceNewlineSniff.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,11 @@ class ClosingBraceNewlineSniff implements Sniff {
3333

3434
public const CODE_MUST_NEWLINE_FOLLOWING_CURLY_BRACKET = 'MustNewlineFollowingCurlyBracket';
3535

36-
/**
37-
* @inheritDoc
38-
*/
39-
public function register() {
36+
public function register() : array {
4037
return [ T_CLOSE_CURLY_BRACKET ];
4138
}
4239

43-
/**
44-
* @inheritDoc
45-
*/
46-
public function process( File $phpcsFile, $stackPtr ) {
40+
public function process( File $phpcsFile, $stackPtr ) : void {
4741
$tokens = $phpcsFile->getTokens();
4842

4943
$prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true);
@@ -68,9 +62,11 @@ public function process( File $phpcsFile, $stackPtr ) {
6862
return;
6963
}
7064

71-
$fix = $phpcsFile->addFixableError('Must be a newline following closing curly bracket',
65+
$fix = $phpcsFile->addFixableError(
66+
'Must be a newline following closing curly bracket',
7267
$stackPtr,
73-
self::CODE_MUST_NEWLINE_FOLLOWING_CURLY_BRACKET);
68+
self::CODE_MUST_NEWLINE_FOLLOWING_CURLY_BRACKET
69+
);
7470
if( $fix ) {
7571
$phpcsFile->fixer->beginChangeset();
7672
$phpcsFile->fixer->addNewline($stackPtr);

src/Corpus/Sniffs/ControlStructures/OpeningOneTrueBraceSniff.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,11 @@ class OpeningOneTrueBraceSniff implements Sniff {
3838

3939
public const CODE_BRACE_ON_NEWLINE = 'BraceOnNewLine';
4040

41-
/**
42-
* @inheritDoc
43-
*/
44-
public function register() {
41+
public function register() : array {
4542
return [ T_OPEN_CURLY_BRACKET ];
4643
}
4744

48-
/**
49-
* @inheritDoc
50-
*/
51-
public function process( File $phpcsFile, $stackPtr ) {
45+
public function process( File $phpcsFile, $stackPtr ) : void {
5246
$tokens = $phpcsFile->getTokens();
5347
$prev = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, 0, true);
5448
if( !$prev || $tokens[$prev]['line'] === $tokens[$stackPtr]['line'] ) {
@@ -67,7 +61,8 @@ public function process( File $phpcsFile, $stackPtr ) {
6761
$fix = $phpcsFile->addFixableError(
6862
'Opening brace should be on the same line as the declaration',
6963
$stackPtr,
70-
self::CODE_BRACE_ON_NEWLINE);
64+
self::CODE_BRACE_ON_NEWLINE
65+
);
7166
if( $fix ) {
7267
$phpcsFile->fixer->beginChangeset();
7368
for( $i = $prev + 1; $i < $stackPtr; $i++ ) {

src/Corpus/Sniffs/General/BinaryOperationNewlineSniff.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,20 @@ class BinaryOperationNewlineSniff implements Sniff {
3434

3535
public const CODE_BOOLEAN_OPERATION_SHOULD_LEAD_LINE = 'BooleanOperationShouldLeadLine';
3636

37-
/**
38-
* @inheritDoc
39-
*/
40-
public function register() {
37+
public function register() : array {
4138
return [ T_BOOLEAN_AND, T_BOOLEAN_OR ];
4239
}
4340

44-
/**
45-
* @inheritDoc
46-
*/
47-
public function process( File $phpcsFile, $stackPtr ) {
41+
public function process( File $phpcsFile, $stackPtr ) : void {
4842
$tokens = $phpcsFile->getTokens();
4943

5044
$nextPtr = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
5145
if( $tokens[$stackPtr]['line'] + 1 !== $tokens[$nextPtr]['line'] ) {
5246
return;
5347
}
5448

55-
$fix = $phpcsFile->addFixableError('Boolean %s should start line and not end previous line',
49+
$fix = $phpcsFile->addFixableError(
50+
'Boolean %s should start line and not end previous line',
5651
$stackPtr,
5752
self::CODE_BOOLEAN_OPERATION_SHOULD_LEAD_LINE,
5853
[ $tokens[$stackPtr]['content'] ]

src/Corpus/Sniffs/General/ReturnTrailingNewlineSniff.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,11 @@ class ReturnTrailingNewlineSniff implements Sniff {
3131

3232
public const CODE_RETURN_HAS_TRAILING_NEWLINE = 'ReturnHasTrailingNewline';
3333

34-
/**
35-
* @inheritDoc
36-
*/
37-
public function register() {
34+
public function register() : array {
3835
return [ T_RETURN ];
3936
}
4037

41-
/**
42-
* @inheritDoc
43-
*/
44-
public function process( File $phpcsFile, $stackPtr ) {
38+
public function process( File $phpcsFile, $stackPtr ) : void {
4539
$tokens = $phpcsFile->getTokens();
4640

4741
$eosPtr = $phpcsFile->findEndOfStatement($stackPtr);

src/Corpus/Sniffs/Methods/MethodParameterFormattingSniff.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@ class MethodParameterFormattingSniff implements Sniff {
3232

3333
public const CODE_OVERLY_LONG_ARGUMENT_LIST = 'OverlyLongArgumentList';
3434

35-
/**
36-
* @inheritDoc
37-
*/
38-
public function register() {
35+
public function register() : array {
3936
return [ T_FUNCTION, T_CLOSURE ];
4037
}
4138

42-
/**
43-
* @inheritDoc
44-
*/
45-
public function process( File $phpcsFile, $stackPtr ) {
39+
public function process( File $phpcsFile, $stackPtr ) : void {
4640
$tokens = $phpcsFile->getTokens();
4741

4842
$scopePtr = $tokens[$stackPtr]['scope_opener'] ?? $phpcsFile->findEndOfStatement($stackPtr);

0 commit comments

Comments
 (0)