Skip to content

Commit de9130a

Browse files
authored
PHP CS Fixer 3 preparation (#500)
1 parent 46ba4b7 commit de9130a

10 files changed

+28
-8
lines changed

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
2626
$rules[$fixer->getName()] = true;
2727
}
2828

29-
return PhpCsFixer\Config::create()
29+
return (new PhpCsFixer\Config())
3030
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
3131
->registerCustomFixers(new PhpCsFixerCustomFixersDev\Fixers())
3232
->setRiskyAllowed(true)

dev-tools/phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
path: ../tests
99
- message: '#^Call to function method_exists\(\) with ''Tests\\\\.*'' and ''.*'' will always evaluate to true\.$#'
1010
path: ../tests
11-
- message: '#^Parameter \#1 \$objectOrClass of class ReflectionClass constructor expects class-string<T of object>\|T of object, string given\.$#'
11+
- message: '#^Parameter \#\d+ \$[a-zA-Z0-9]+ of class ReflectionClass constructor expects class-string<T of object>\|T of object, string given\.$#'
1212
path: ../tests
1313
level: max
1414
paths:

dev-tools/src/Fixer/OrderedClassElementsInternalFixer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace PhpCsFixerCustomFixersDev\Fixer {
1515
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
1616
use PhpCsFixer\Fixer\FixerInterface;
17+
use PhpCsFixer\FixerDefinition\FixerDefinition;
18+
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
1719
use PhpCsFixer\Tokenizer\Tokens;
1820

1921
/**
@@ -35,6 +37,11 @@ final class OrderedClassElementsInternalFixer implements FixerInterface
3537
'getSuccessorsNames',
3638
];
3739

40+
public function getDefinition(): FixerDefinitionInterface
41+
{
42+
return new FixerDefinition('Internal fixer for class elements order.', []);
43+
}
44+
3845
/** @var OrderedClassElementsFixer */
3946
private $orderedClassElementsFixer;
4047

dev-tools/src/Fixer/PriorityInternalFixer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace PhpCsFixerCustomFixersDev\Fixer;
1515

1616
use PhpCsFixer\Fixer\FixerInterface;
17+
use PhpCsFixer\FixerDefinition\FixerDefinition;
18+
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
1719
use PhpCsFixer\Tokenizer\Token;
1820
use PhpCsFixer\Tokenizer\Tokens;
1921
use PhpCsFixer\Utils;
@@ -29,6 +31,11 @@ public function getName(): string
2931
return 'Internal/' . \strtolower(\str_replace('\\', '_', Utils::camelCaseToUnderscore(__CLASS__)));
3032
}
3133

34+
public function getDefinition(): FixerDefinitionInterface
35+
{
36+
return new FixerDefinition('Internal fixer for priorities.', []);
37+
}
38+
3239
public function getPriority(): int
3340
{
3441
return 1000;

src/Fixer/CommentedOutFunctionFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1717
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
18+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1819
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1920
use PhpCsFixer\FixerDefinition\CodeSample;
2021
use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -42,7 +43,7 @@ public function getDefinition(): FixerDefinitionInterface
4243
);
4344
}
4445

45-
public function getConfigurationDefinition(): FixerConfigurationResolver
46+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
4647
{
4748
return new FixerConfigurationResolver([
4849
(new FixerOptionBuilder('functions', 'list of functions to comment out'))

src/Fixer/DataProviderNameFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1717
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
18+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1819
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1920
use PhpCsFixer\FixerDefinition\CodeSample;
2021
use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -55,7 +56,7 @@ public function dataProvider() {}
5556
);
5657
}
5758

58-
public function getConfigurationDefinition(): FixerConfigurationResolver
59+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
5960
{
6061
return new FixerConfigurationResolver([
6162
(new FixerOptionBuilder('prefix', 'prefix that replaces "test"'))

src/Fixer/NoSuperfluousConcatenationFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1717
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
18+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1819
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1920
use PhpCsFixer\FixerDefinition\CodeSample;
2021
use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -36,7 +37,7 @@ public function getDefinition(): FixerDefinitionInterface
3637
);
3738
}
3839

39-
public function getConfigurationDefinition(): FixerConfigurationResolver
40+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
4041
{
4142
return new FixerConfigurationResolver([
4243
(new FixerOptionBuilder('allow_preventing_trailing_spaces', 'whether to keep concatenation if it prevents having trailing spaces in string'))

src/Fixer/NumericLiteralSeparatorFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1717
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
18+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1819
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1920
use PhpCsFixer\FixerDefinition\FixerDefinition;
2021
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
@@ -58,7 +59,7 @@ public function getDefinition(): FixerDefinitionInterface
5859
);
5960
}
6061

61-
public function getConfigurationDefinition(): FixerConfigurationResolver
62+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
6263
{
6364
return new FixerConfigurationResolver([
6465
(new FixerOptionBuilder('binary', 'whether add, remove or ignore separators in binary numbers.'))

src/Fixer/PhpdocOnlyAllowedAnnotationsFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PhpCsFixer\DocBlock\DocBlock;
1717
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1818
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
19+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1920
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
2021
use PhpCsFixer\FixerDefinition\CodeSample;
2122
use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -48,7 +49,7 @@ function foo_bar() {}
4849
);
4950
}
5051

51-
public function getConfigurationDefinition(): FixerConfigurationResolver
52+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
5253
{
5354
return new FixerConfigurationResolver([
5455
(new FixerOptionBuilder('elements', 'list of annotations to keep in PHPDoc'))

src/Fixer/SingleSpaceAfterStatementFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1717
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
18+
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1819
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1920
use PhpCsFixer\FixerDefinition\CodeSample;
2021
use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -91,7 +92,7 @@ public function getDefinition(): FixerDefinitionInterface
9192
);
9293
}
9394

94-
public function getConfigurationDefinition(): FixerConfigurationResolver
95+
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
9596
{
9697
return new FixerConfigurationResolver([
9798
(new FixerOptionBuilder('allow_linebreak', 'whether to allow statement followed by linebreak'))

0 commit comments

Comments
 (0)