Skip to content

Add withSetProviders method#6515

Merged
TomasVotruba merged 2 commits intorectorphp:mainfrom
ghostwriter:oss/rectorphp/rector/issues/8720
Jan 11, 2025
Merged

Add withSetProviders method#6515
TomasVotruba merged 2 commits intorectorphp:mainfrom
ghostwriter:oss/rectorphp/rector/issues/8720

Conversation

@ghostwriter
Copy link
Contributor

This patch resolves rectorphp/rector#8720 (comment), via the following changes:

  • Add a new withSetProviders method, to add set provider class names to the setProviders array, including validation to ensure they implement the SetProviderInterface.

  • Modified the __invoke method to handle both setGroups and setProviders when creating a SetManager instance.

<?php

declare(strict_types=1);

use Vendor\Package\RectorSetProvider;
use Vendor\Package\ComposerSetProvider;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
           ->withSetProviders(
               RectorSetProvider::class,
               ComposerSetProvider::class
           );

Note: I haven't added tests, but this can serve as a starting point, if you like the idea.

Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
@TomasVotruba TomasVotruba merged commit 0a6eb12 into rectorphp:main Jan 11, 2025
@TomasVotruba
Copy link
Member

Thank you, looks good to me 👍

@ghostwriter ghostwriter deleted the oss/rectorphp/rector/issues/8720 branch January 11, 2025 19:02
@github-actions
Copy link
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add withSetProviders method for Registering SetProviderInterface

3 participants