Skip to content

Commit

Permalink
Merge pull request #241 from ergebnis/fix/deprecated
Browse files Browse the repository at this point in the history
Fix: Do not enable deprecated fixers
  • Loading branch information
ergebnis-bot committed Nov 1, 2020
2 parents 50c1354 + 1c907cb commit 5d4d140
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 23 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

For a full diff see [`2.5.1...main`][2.5.1...main].
For a full diff see [`2.5.2...main`][2.5.2...main].

## [`2.5.2`][2.5.2]

For a full diff see [`2.5.1...2.5.2`][2.5.1...2.5.2].

### Fixed

* Enabled and configured proxied instead of deprecated fixers ([#241]), by [@dependabot]

## [`2.5.1`][2.5.1]

Expand Down Expand Up @@ -130,6 +138,7 @@ For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0].
[2.4.0]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/2.4.0
[2.5.0]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/2.5.0
[2.5.1]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/2.5.1
[2.5.2]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/2.5.2

[d899e77...1.0.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/d899e77...1.0.0
[1.0.0...1.1.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/1.0.0...1.1.0
Expand All @@ -145,7 +154,8 @@ For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0].
[2.3.0...2.4.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.3.0...2.4.0
[2.4.0...2.5.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.4.0...2.5.0
[2.5.0...2.5.1]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.5.0...2.5.1
[2.5.1...main]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.5.1...main
[2.5.1...2.5.2]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.5.1...2.5.2
[2.5.2...main]: https://github.com/ergebnis/php-cs-fixer-config/compare/2.5.2...main

[#3]: https://github.com/ergebnis/php-cs-fixer-config/pull/3
[#14]: https://github.com/ergebnis/php-cs-fixer-config/pull/14
Expand All @@ -160,6 +170,7 @@ For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0].
[#215]: https://github.com/ergebnis/php-cs-fixer-config/pull/215
[#220]: https://github.com/ergebnis/php-cs-fixer-config/pull/220
[#226]: https://github.com/ergebnis/php-cs-fixer-config/pull/226
[#241]: https://github.com/ergebnis/php-cs-fixer-config/pull/241

[@dependabot]: https://github.com/apps/dependabot
[@linuxjuggler]: https://github.com/linuxjuggler
Expand Down
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<code>getFixers</code>
<code>registerBuiltInFixers</code>
</InternalMethod>
<MissingClosureParamType occurrences="1">
<code>$ruleConfiguration</code>
</MissingClosureParamType>
<MixedMethodCall occurrences="1">
<code>getRules</code>
</MixedMethodCall>
Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/Laravel6.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ final class Laravel6 extends AbstractRuleSet
'list_syntax' => false,
'logical_operators' => false,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_constants' => false,
'lowercase_keywords' => true,
'lowercase_static_reference' => true, // added from Symfony
'magic_constant_casing' => true,
Expand Down
8 changes: 6 additions & 2 deletions src/RuleSet/Php71.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final class Php71 extends AbstractRuleSet
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => false,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -337,7 +337,11 @@ final class Php71 extends AbstractRuleSet
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down
8 changes: 6 additions & 2 deletions src/RuleSet/Php73.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final class Php73 extends AbstractRuleSet
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => true,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -337,7 +337,11 @@ final class Php73 extends AbstractRuleSet
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down
8 changes: 6 additions & 2 deletions src/RuleSet/Php74.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final class Php74 extends AbstractRuleSet
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => true,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -337,7 +337,11 @@ final class Php74 extends AbstractRuleSet
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down
58 changes: 51 additions & 7 deletions test/Unit/RuleSet/AbstractRuleSetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,37 @@ final public function testRulesDoNotContainRuleSets(): void
));
}

final public function testRulesDoNotEnableDeprecatedFixers(): void
{
$fixers = self::builtInFixers();

$rulesEnablingDeprecatedFixers = \array_filter(
self::createRuleSet()->rules(),
static function ($ruleConfiguration, string $ruleName) use ($fixers): bool {
if (false === $ruleConfiguration) {
return false;
}

if (!\array_key_exists($ruleName, $fixers)) {
return false;
}

$fixer = $fixers[$ruleName];

return $fixer instanceof Fixer\DeprecatedFixerInterface;
},
\ARRAY_FILTER_USE_BOTH
);

$namesOfEnabledDeprecatedFixers = \array_keys($rulesEnablingDeprecatedFixers);

self::assertEmpty($namesOfEnabledDeprecatedFixers, \sprintf(
"Failed asserting that deprecated fixers with names\n\n%s\n\nare not enabled in rule set \"%s\".",
' - ' . \implode("\n - ", $namesOfEnabledDeprecatedFixers),
static::className()
));
}

/**
* @phpstan-return class-string
*
Expand Down Expand Up @@ -228,20 +259,33 @@ final protected static function createRuleSet(?string $header = null): Config\Ru
}

/**
* @return array<int, string>
* @return array<string, Fixer\FixerInterface>
*/
private static function builtInFixerNames(): array
private static function builtInFixers(): array
{
$fixerFactory = FixerFactory::create();

$fixerFactory->registerBuiltInFixers();

/** @var array<int, string> $builtInFixerNames */
$builtInFixerNames = \array_values(\array_map(static function (Fixer\FixerInterface $fixer): string {
return $fixer->getName();
}, $fixerFactory->getFixers()));
$fixers = $fixerFactory->getFixers();

/** @var array<string, Fixer\FixerInterface> $builtInFixers */
$builtInFixers = \array_combine(
\array_map(static function (Fixer\FixerInterface $fixer): string {
return $fixer->getName();
}, $fixers),
$fixers
);

return $builtInFixers;
}

return $builtInFixerNames;
/**
* @return array<int, string>
*/
private static function builtInFixerNames(): array
{
return \array_keys(self::builtInFixers());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/RuleSet/Laravel6Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class Laravel6Test extends AbstractRuleSetTestCase
'list_syntax' => false,
'logical_operators' => false,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_constants' => false,
'lowercase_keywords' => true,
'lowercase_static_reference' => true, // added from Symfony
'magic_constant_casing' => true,
Expand Down
8 changes: 6 additions & 2 deletions test/Unit/RuleSet/Php71Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final class Php71Test extends AbstractRuleSetTestCase
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => false,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -343,7 +343,11 @@ final class Php71Test extends AbstractRuleSetTestCase
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down
8 changes: 6 additions & 2 deletions test/Unit/RuleSet/Php73Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final class Php73Test extends AbstractRuleSetTestCase
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => true,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -343,7 +343,11 @@ final class Php73Test extends AbstractRuleSetTestCase
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down
8 changes: 6 additions & 2 deletions test/Unit/RuleSet/Php74Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final class Php74Test extends AbstractRuleSetTestCase
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false,
'global_namespace_import' => false,
'hash_to_slash_comment' => true,
'hash_to_slash_comment' => false,
'header_comment' => false,
'heredoc_indentation' => true,
'heredoc_to_nowdoc' => true,
Expand Down Expand Up @@ -343,7 +343,11 @@ final class Php74Test extends AbstractRuleSetTestCase
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => false,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_line_throw' => false,
'single_quote' => true,
'single_trait_insert_per_statement' => true,
Expand Down

0 comments on commit 5d4d140

Please sign in to comment.