Skip to content

Commit cddb6d7

Browse files
authored
DataProviderStaticFixer - make risky based on config (#747)
1 parent 55dbe67 commit cddb6d7

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.dev-tools/src/Readme/ReadmeCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PhpCsFixer\Tokenizer\Tokens;
2121
use PhpCsFixer\WhitespacesFixerConfig;
2222
use PhpCsFixerCustomFixers\Fixer\AbstractFixer;
23+
use PhpCsFixerCustomFixers\Fixer\DataProviderStaticFixer;
2324
use PhpCsFixerCustomFixers\Fixer\DeprecatingFixerInterface;
2425
use PhpCsFixerCustomFixers\Fixers;
2526
use SebastianBergmann\Diff\Differ;
@@ -186,12 +187,18 @@ private function fixers(): string
186187

187188
$output .= $fixer instanceof DeprecatedFixerInterface ? \sprintf("\n DEPRECATED: use `%s` instead.", \implode('`, `', $fixer->getSuccessorsNames())) : '';
188189

190+
if ($fixer instanceof DataProviderStaticFixer) {
191+
$fixer->configure(['force' => true]);
192+
}
189193
if ($fixer->isRisky()) {
190194
$output .= \sprintf(
191195
"\n *Risky: %s.*",
192196
$fixer->getDefinition()->getRiskyDescription()
193197
);
194198
}
199+
if ($fixer instanceof DataProviderStaticFixer) {
200+
$fixer->configure(['force' => false]);
201+
}
195202

196203
if ($fixer instanceof ConfigurableFixerInterface) {
197204
$output .= "\nConfiguration options:";

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
44
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
55
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
6-
![Tests](https://img.shields.io/badge/tests-3374-brightgreen.svg)
6+
![Tests](https://img.shields.io/badge/tests-3375-brightgreen.svg)
77
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
88

99
[![CI Status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/workflows/CI/badge.svg?branch=main)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions)

src/Fixer/DataProviderStaticFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function isCandidate(Tokens $tokens): bool
8383

8484
public function isRisky(): bool
8585
{
86-
return true;
86+
return $this->force;
8787
}
8888

8989
public function fix(\SplFileInfo $file, Tokens $tokens): void

tests/Fixer/DataProviderStaticFixerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
*/
1919
final class DataProviderStaticFixerTest extends AbstractFixerTestCase
2020
{
21-
public function testIsRisky(): void
21+
public function testIsRiskyWithForceOption(): void
2222
{
23+
$this->fixer->configure(['force' => true]);
2324
self::assertTrue($this->fixer->isRisky());
2425
}
2526

27+
public function testIsNotRiskyWithoutForceOption(): void
28+
{
29+
self::assertFalse($this->fixer->isRisky());
30+
}
31+
2632
public function testConfiguration(): void
2733
{
2834
$options = $this->fixer->getConfigurationDefinition()->getOptions();

0 commit comments

Comments
 (0)