Skip to content

Commit

Permalink
[DX] Warn about ->withPhpSets() called multiple times, to avoid inval…
Browse files Browse the repository at this point in the history
…id set mix (#6632)

* [DX] Warn about ->withPhpSets() called multiple times, to avoid invalid set mix

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
TomasVotruba and actions-user authored Dec 27, 2024
1 parent 5f21af7 commit 7bbe9ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ final class RectorConfigBuilder

private ?string $editorUrl = null;

/**
* @api soon to be used
*/
private ?bool $isWithPhpSetsUsed = null;

private ?bool $isWithPhpLevelUsed = null;
Expand Down Expand Up @@ -533,6 +530,14 @@ public function withPhpSets(
bool $php53 = false,
bool $php84 = false, // place on later as BC break when used in php 7.x without named arg
): self {
if ($this->isWithPhpSetsUsed === true) {
throw new InvalidConfigurationException(sprintf(
'Method "%s()" can be called only once. It always includes all previous sets UP TO the defined version.%sThe best practise is to call it once with no argument. That way it will pick up PHP version from composer.json and your project will always stay up to date.',
__METHOD__,
PHP_EOL
));
}

$this->isWithPhpSetsUsed = true;

$pickedArguments = array_filter(func_get_args());
Expand Down

0 comments on commit 7bbe9ba

Please sign in to comment.