diff --git a/composer.lock b/composer.lock index 1c3436f41..82992b16d 100644 --- a/composer.lock +++ b/composer.lock @@ -3263,12 +3263,12 @@ "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "5b33bdd871895276e2c18e5410a4a57df9233ee0" + "reference": "adf15bb534fb2d71dafe047e112dcf89bb7e6d55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/5b33bdd871895276e2c18e5410a4a57df9233ee0", - "reference": "5b33bdd871895276e2c18e5410a4a57df9233ee0", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/adf15bb534fb2d71dafe047e112dcf89bb7e6d55", + "reference": "adf15bb534fb2d71dafe047e112dcf89bb7e6d55", "shasum": "" }, "require": { @@ -3307,7 +3307,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/1.2.7" + "source": "https://github.com/rectorphp/rector/tree/main" }, "funding": [ { @@ -3315,7 +3315,7 @@ "type": "github" } ], - "time": "2024-10-12T11:12:46+00:00" + "time": "2024-10-15T14:39:32+00:00" }, { "name": "samsonasik/array-lookup", @@ -6914,16 +6914,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.32.0", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -6955,9 +6955,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2024-09-26T07:23:32+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/Sets/RectorSetsTreeProvider.php b/src/Sets/RectorSetsTreeProvider.php index 671ab8ecf..13a625291 100644 --- a/src/Sets/RectorSetsTreeProvider.php +++ b/src/Sets/RectorSetsTreeProvider.php @@ -4,9 +4,11 @@ namespace App\Sets; +use ReflectionProperty; use App\RuleFilter\ValueObject\RectorSet; use Rector\Bridge\SetProviderCollector; -use Rector\Bridge\SetRectorsResolver; +use Rector\Config\RectorConfig; +use Rector\Contract\Rector\RectorInterface; use Rector\Set\Contract\SetInterface; use RectorLaravel\Set\LaravelSetProvider; use Webmozart\Assert\Assert; @@ -88,6 +90,28 @@ public function provideCommunity(): array return $communityRectorSets; } + /** + * @return array> + */ + public function resolveFromFilePath(string $configFilePath): array + { + Assert::fileExists($configFilePath); + + $rectorConfig = new RectorConfig(); + /** @var callable $configCallable */ + $configCallable = require $configFilePath; + $configCallable($rectorConfig); + + // get tagged class-names + $tagsReflectionProperty = new ReflectionProperty($rectorConfig, 'tags'); + $tags = $tagsReflectionProperty->getValue($rectorConfig); + + $rectorClasses = $tags[RectorInterface::class] ?? []; + sort($rectorClasses); + + return array_unique($rectorClasses); + } + /** * @param SetInterface[] $sets * @return RectorSet[] @@ -95,12 +119,10 @@ public function provideCommunity(): array private function createRectorSetsFromSetProviders(array $sets): array { Assert::allIsInstanceOf($sets, SetInterface::class); - - $setRectorsResolver = new SetRectorsResolver(); $rectorSets = []; foreach ($sets as $set) { - $rectorClasses = $setRectorsResolver->resolveFromFilePath($set->getSetFilePath()); + $rectorClasses = $this->resolveFromFilePath($set->getSetFilePath()); $rectorSets[] = new RectorSet($set->getGroupName(), $set->getName(), $rectorClasses); }