Skip to content

Commit 0ee9020

Browse files
authored
Few tiny fixes (#6277)
1 parent 3aa886f commit 0ee9020

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/Config/RectorConfig.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
final class RectorConfig extends Container
3232
{
3333
/**
34-
* @var array<class-string<RectorInterface>, mixed[]>>
34+
* @var array<class-string<ConfigurableRectorInterface>, mixed[]>>
3535
*/
3636
private array $ruleConfigurations = [];
3737

@@ -418,4 +418,22 @@ public function reportingRealPath(bool $absolute = true): void
418418
{
419419
SimpleParameterProvider::setParameter(Option::ABSOLUTE_FILE_PATH, $absolute);
420420
}
421+
422+
/**
423+
* @internal Used only for bridge
424+
* @return array<class-string<ConfigurableRectorInterface>, mixed>
425+
*/
426+
public function getRuleConfigurations(): array
427+
{
428+
return $this->ruleConfigurations;
429+
}
430+
431+
/**
432+
* @internal Used only for bridge
433+
* @return array<class-string<RectorInterface>>
434+
*/
435+
public function getRectorClasses(): array
436+
{
437+
return $this->tags[RectorInterface::class] ?? [];
438+
}
421439
}

src/Configuration/Levels/LevelRulesResolver.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ final class LevelRulesResolver
1616
*/
1717
public static function resolve(int $level, array $availableRules, string $methodName): array
1818
{
19+
// level < 0 is not allowed
20+
Assert::natural($level, sprintf('Level must be >= 0 on %s', $methodName));
21+
22+
Assert::allIsAOf($availableRules, RectorInterface::class);
23+
1924
$rulesCount = count($availableRules);
2025

2126
if ($availableRules === []) {
2227
throw new ShouldNotHappenException(sprintf(
23-
'There is no available rules in %s, define the available rules first',
28+
'There are no available rules in "%s()", define the available rules first',
2429
$methodName
2530
));
2631
}
2732

28-
// level < 0 is not allowed
29-
Assert::natural($level, sprintf('Level must be >= 0 on %s', $methodName));
30-
3133
// start with 0
3234
$maxLevel = $rulesCount - 1;
3335
if ($level > $maxLevel) {

0 commit comments

Comments
 (0)