Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
},
"require-dev": {
"nette/robot-loader": "^4.1",
"symfony/process": "^8.1",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
Expand All @@ -52,6 +51,7 @@
"rector/jack": "^1.1",
"rector/swiss-knife": "^2.4.1",
"shipmonk/composer-dependency-analyser": "^1.8",
"symfony/process": "^8.1",
"symplify/easy-coding-standard": "^13.2.13",
"symplify/phpstan-rules": "^14.13",
"tomasvotruba/class-leak": "^2.1",
Expand Down
9 changes: 7 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ parameters:
# EARLY_RETURN set is deprecated (empty, merged into code-quality), still mapped internally until removed
-
identifier: classConstant.deprecated
message: '#EARLY_RETURN of class Rector\\Set\\ValueObject\\SetList#'
path: src/Configuration/RectorConfigBuilder.php
paths:
- src/Configuration/RectorConfigBuilder.php

# the deprecated github/gitlab output formatters are still tested until removed in next minor version
-
Expand Down Expand Up @@ -310,6 +310,7 @@ parameters:
paths:
- bin/rector.php
- src/Bootstrap/ExtensionConfigResolver.php
- src/Configuration/RectorConfigBuilder.php
- src/Validation/RectorConfigValidator.php
- src/Testing/PHPUnit/AbstractLazyTestCase.php
- src/Reporting/DeprecatedRulesReporter.php
Expand Down Expand Up @@ -341,6 +342,10 @@ parameters:
message: '#@\\ini_set\(.*\)" is forbidden to use#'
path: bin/rector.php

-
message: '#PHPDoc tag @var with type array<string> is not subtype of native type array#'
path: src/Bootstrap/ExtensionConfigResolver.php

-
identifier: symplify.forbiddenStaticClassConstFetch
message: '#Avoid static access of constants, as they can change value\. Use interface and contract method instead#'
Expand Down
36 changes: 7 additions & 29 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
use Rector\Exception\Configuration\InvalidConfigurationException;
use Rector\Php\PhpVersionResolver\ComposerJsonPhpVersionResolver;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\Enum\SetGroup;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyInternalSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\TwigSetList;
use Rector\ValueObject\Configuration\LevelOverflow;
use Rector\ValueObject\PhpVersion;
use RectorLaravel\Set\LaravelSetList;
use Symfony\Component\Finder\Finder;
use Webmozart\Assert\Assert;

Expand All @@ -56,17 +56,6 @@ final class RectorConfigBuilder
'withCodingStyleLevel' => [SetList::CODING_STYLE, 'coding style'],
];

/**
* The composer-based set of the extensions that rector-src does not require, so their set list class cannot be
* imported here. Resolved at run-time; an extension that ships no such set falls back to its set group.
*
* @var array<SetGroup::*, string>
*/
private const array EXTENSION_COMPOSER_BASED_SET_LISTS = [
SetGroup::LARAVEL => 'RectorLaravel\\Set\\LaravelSetList::COMPOSER_BASED',
SetGroup::DRUPAL => 'DrupalRector\\Set\\DrupalSetList::COMPOSER_BASED',
];

/**
* @var string[]
*/
Expand Down Expand Up @@ -693,24 +682,13 @@ public function withComposerBased(
bool $laravel = false,
bool $drupal = false,
): self {
$setMap = [
SetGroup::LARAVEL => $laravel,
SetGroup::DRUPAL => $drupal,
];

foreach ($setMap as $setGroup => $isEnabled) {
if (! $isEnabled) {
continue;
}

$setListConstant = self::EXTENSION_COMPOSER_BASED_SET_LISTS[$setGroup];
if (defined($setListConstant)) {
$setFilePath = constant($setListConstant);
Assert::string($setFilePath);
if ($laravel && class_exists('RectorLaravel\Set\LaravelSetList') && constant('RectorLaravel\Set\LaravelSetList::COMPOSER_BASED')) {
$this->sets[] = LaravelSetList::COMPOSER_BASED;
}

// single set, as every rule inside is bound to the installed package version on its own
$this->sets[] = $setFilePath;
}
if ($drupal && class_exists('DrupalRector\Set\DrupalSetList') && constant('DrupalRector\Set\DrupalSetList::COMPOSER_BASED')) {
// waits on https://github.com/palantirnet/drupal-rector/pull/419/files#diff-c6bd4ee854830efc1363a7d99c1b6a2e7e64f2499a51e503174ab777de7e64e5
$this->sets[] = \DrupalRector\Set\DrupalSetList::COMPOSER_BASED;
}

if ($phpunit) {
Expand Down
2 changes: 2 additions & 0 deletions src/Set/Enum/SetGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ final class SetGroup
public const string PHP = 'php';

/**
* @deprecated Use composer-based.php set instead
* Version-based set provider
*/
public const string LARAVEL = 'laravel';

/**
* @deprecated Use composer-based.php set instead
* Version-based set provider
*/
public const string DRUPAL = 'drupal';
Expand Down
72 changes: 0 additions & 72 deletions tests/Configuration/ExtensionComposerBasedSetTest.php

This file was deleted.

Loading