Skip to content

Commit 83fff25

Browse files
committed
ruleset interface improvements
1 parent 4f403c3 commit 83fff25

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

psalm.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@
1313
<directory name="vendor" />
1414
</ignoreFiles>
1515
</projectFiles>
16+
<issueHandlers>
17+
<MixedReturnTypeCoercion>
18+
<errorLevel type="suppress">
19+
<directory name="src"/>
20+
</errorLevel>
21+
</MixedReturnTypeCoercion>
22+
</issueHandlers>
1623
</psalm>

src/Factory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ public static function fromRuleSet(RuleSetInterface $ruleSet, array $overrideRul
1616
$config = new Config($ruleSet->name());
1717

1818
$config
19-
->setRiskyAllowed(true)
19+
->setRiskyAllowed($ruleSet->getRiskyAllowed())
2020
->setRules(array_merge(
2121
$ruleSet->rules(),
2222
$overrideRules
2323
))
24-
->registerCustomFixers(new \PhpCsFixerCustomFixers\Fixers())
25-
->registerCustomFixers(new \PedroTroller\CS\Fixer\Fixers())
24+
->registerCustomFixers($ruleSet->getCustomFixers())
2625
;
2726

2827
return $config;

src/RuleSet/Php74.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,15 @@ public function rules(): array
9797
'PedroTroller/line_break_between_statements' => true,
9898
];
9999
}
100+
101+
public function getCustomFixers(): iterable
102+
{
103+
yield from new \PhpCsFixerCustomFixers\Fixers();
104+
yield from new \PedroTroller\CS\Fixer\Fixers();
105+
}
106+
107+
public function getRiskyAllowed(): bool
108+
{
109+
return true;
110+
}
100111
}

src/RuleSet/Php80.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,15 @@ public function rules(): array
9797
'PedroTroller/line_break_between_statements' => true,
9898
];
9999
}
100+
101+
public function getCustomFixers(): iterable
102+
{
103+
yield from new \PhpCsFixerCustomFixers\Fixers();
104+
yield from new \PedroTroller\CS\Fixer\Fixers();
105+
}
106+
107+
public function getRiskyAllowed(): bool
108+
{
109+
return true;
110+
}
100111
}

src/RuleSetInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace VisualCraft\PhpCsFixerConfig;
66

7+
use PhpCsFixer\Fixer\FixerInterface;
8+
79
interface RuleSetInterface
810
{
911
/**
@@ -17,4 +19,11 @@ public function name(): string;
1719
* @psalm-return array<string, array|bool>
1820
*/
1921
public function rules(): array;
22+
23+
/**
24+
* @return iterable<array-key, FixerInterface>
25+
*/
26+
public function getCustomFixers(): iterable;
27+
28+
public function getRiskyAllowed(): bool;
2029
}

0 commit comments

Comments
 (0)