Skip to content

Commit

Permalink
Merge multiple calls of phpstanConfig and phpstanConfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Aug 16, 2023
1 parent 446492e commit c915c41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
18 changes: 9 additions & 9 deletions packages/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,29 @@ public function importShortClasses(bool $importShortClasses = true): void
}

/**
* Set PHPStan custom config to load extensions and custom configuration to Rector.
* By default, the "phpstan.neon" path is used.
* Add PHPStan custom config to load extensions and custom configuration to Rector.
*/
public function phpstanConfig(string $filePath): void
{
Assert::fileExists($filePath);

SimpleParameterProvider::setParameter(Option::PHPSTAN_FOR_RECTOR_PATH, $filePath);
$paths = SimpleParameterProvider::provideArrayParameter(Option::PHPSTAN_FOR_RECTOR_PATHS);

$paths[] = $filePath;

SimpleParameterProvider::setParameter(Option::PHPSTAN_FOR_RECTOR_PATHS, $paths);
}

/**
* Set PHPStan custom config to load extensions and custom configuration to Rector.
* By default, the "phpstan.neon" path is used.
* Add PHPStan custom configs to load extensions and custom configuration to Rector.
*
* @param string[] $filePath
* @param string[] $filePaths
*/
public function phpstanConfigs(array $filePaths): void
{
foreach ($filePaths as $filePath) {
Assert::fileExists($filePaths);
$this->phpstanConfig($filePath);
}

SimpleParameterProvider::setParameter(Option::PHPSTAN_FOR_RECTOR_PATHS, $filePaths);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ private function resolveAdditionalConfigFiles(): array
{
$additionalConfigFiles = [];

if (SimpleParameterProvider::hasParameter(Option::PHPSTAN_FOR_RECTOR_PATH)) {
$additionalConfigFiles[] = SimpleParameterProvider::provideStringParameter(Option::PHPSTAN_FOR_RECTOR_PATH);
}

if (SimpleParameterProvider::hasParameter(Option::PHPSTAN_FOR_RECTOR_PATHS)) {
$paths = SimpleParameterProvider::provideArrayParameter(Option::PHPSTAN_FOR_RECTOR_PATHS);
foreach ($paths as $path) {
Expand Down
6 changes: 0 additions & 6 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ final class Option
* @internal Use @see \Rector\Config\RectorConfig::phpstanConfig() instead
* @var string
*/
public const PHPSTAN_FOR_RECTOR_PATH = 'phpstan_for_rector_path';

/**
* @internal Use @see \Rector\Config\RectorConfig::phpstanConfigs() instead
* @var string
*/
public const PHPSTAN_FOR_RECTOR_PATHS = 'phpstan_for_rector_paths';

/**
Expand Down

0 comments on commit c915c41

Please sign in to comment.