Skip to content

Commit

Permalink
Force data providers to be static (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored Nov 27, 2022
1 parent 65c9b60 commit 41bf723
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dev/Builder/Modifier/NonDefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Dev\Builder\Modifier;

use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixerCustomFixers\Fixer\DataProviderStaticFixer;

/**
* @internal
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __invoke(array $rules): array
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays', 'parameters']];
$rules['whitespace_after_comma_in_array'] = ['ensure_single_space' => true];
$rules['yoda_style'] = ['equal' => false, 'identical' => false, 'less_and_greater' => false];
$rules[DataProviderStaticFixer::name()] = ['force' => true];

return $rules;
}
Expand Down
6 changes: 3 additions & 3 deletions dev/Test/Builder/Modifier/UnwantedRulesFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function testRuleIsNotDeprecated(string $name): void
self::assertNotInstanceOf(DeprecatedFixerInterface::class, $this->getFixer($name, true));
}

public function provideRuleIsNotDeprecatedCases(): iterable
public static function provideRuleIsNotDeprecatedCases(): iterable
{
foreach ($this->getRules() as $name) {
foreach (self::getRules() as $name) {
yield $name => [$name];
}
}
Expand All @@ -65,7 +65,7 @@ private function getFixer(string $name, $config): FixerInterface
/**
* @return array<string>
*/
private function getRules(): array
private static function getRules(): array
{
$reflection = new \ReflectionClass(UnwantedRulesFilter::class);

Expand Down
4 changes: 3 additions & 1 deletion src/Rules/LibraryRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ public function getRules(): array
Fixer\ConstructorEmptyBracesFixer::name() => true,
Fixer\DataProviderNameFixer::name() => true,
Fixer\DataProviderReturnTypeFixer::name() => true,
Fixer\DataProviderStaticFixer::name() => true,
Fixer\DataProviderStaticFixer::name() => [
'force' => true,
],
Fixer\DeclareAfterOpeningTagFixer::name() => true,
Fixer\IssetToArrayKeyExistsFixer::name() => true,
Fixer\MultilineCommentOpeningClosingAloneFixer::name() => true,
Expand Down
4 changes: 3 additions & 1 deletion src/Rules/ProjectRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ public function getRules(): array
Fixer\ConstructorEmptyBracesFixer::name() => true,
Fixer\DataProviderNameFixer::name() => true,
Fixer\DataProviderReturnTypeFixer::name() => true,
Fixer\DataProviderStaticFixer::name() => true,
Fixer\DataProviderStaticFixer::name() => [
'force' => true,
],
Fixer\DeclareAfterOpeningTagFixer::name() => true,
Fixer\IssetToArrayKeyExistsFixer::name() => true,
Fixer\MultilineCommentOpeningClosingAloneFixer::name() => true,
Expand Down

0 comments on commit 41bf723

Please sign in to comment.