Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove requirement of framework specific rectors #5976

Closed
olivernybroe opened this issue Mar 24, 2021 · 14 comments
Closed

Remove requirement of framework specific rectors #5976

olivernybroe opened this issue Mar 24, 2021 · 14 comments
Labels

Comments

@olivernybroe
Copy link
Contributor

olivernybroe commented Mar 24, 2021

Feature Request

I love that we now have packages for the framework specific rectors, however I think we could benefit from removing them as a requirement in the base of rector.

E.g. I am a Laravel developer, so I really don't need to have cakephp and so on rectors included in my codebase.

Pros

Smaller package size
For me, as I would only require the Laravel rector package, my filesize would be reduced with about 1.2 MB 👍

Cons

User's having to require another package before they can use rector. + would this work correctly when using prefixed rector?

@samsonasik
Copy link
Member

samsonasik commented Mar 24, 2021

The inclusion seems currently used to avoid direct BC break, see deprecation at:

/**
* @deprecated
* @see Use CakePHPSetList instead
* @var string
*/
public const CAKEPHP_30 = CakePHPSetList::CAKEPHP_30;

Also, on service rule usage, removing it means the VerifyRectorServiceExistsCompilerPass will need to have updated message when service not found, eg:

sprintf('Rector rule "%s" not found, please verify that the rule exists', $class)

for more verbose message, like addition information:

You may need to find in separate rector rules package (installable via composer):

- rector/rector-cakephp
- rector/rector-laravel
...

@TomasVotruba
Copy link
Member

TomasVotruba commented Mar 24, 2021

Hi @olivernybroe ,

that's something we plan for one of next releases. We want to take it step by step, so community adapts the change slowly.

The hard question now is:

  • How can we allow use of packages like rector/rector-phpunit in prefixed/PHP 7.1 downgraded version?

Once we have this answer, we can move on.

@lulco
Copy link
Contributor

lulco commented Apr 4, 2021

Hi all,
imho the main problem is we need to allow rector/rector-* packages to work with rector/rector and also with rector/rector-prefixed version right?

If not, stop reading and ignore next lines :D

So we need something like or in composer:

"require": {
    "rector/rector or rector/rector-prefixed": "^0.10"
}

There are several issues about this problem in composer repository and there is also one solution it could work (I've never use it just read about it):
composer/composer#751 (comment)

If both packages rector/rector and rector/rector-prefixed will provide the same "interface" like:

"provide": {
    "rector/rector-abcdefg": "0.10.3" // TODO find the name instead of abcdefg, TODO try if version could be self.version
}

Then all rector/rector-* packages could require this "rector/rector-abcdefg" and the final decision of what will be installed is up to user (or script) if he/she/it will require rector/rector or rector/rector-prefixed

@olivernybroe
Copy link
Contributor Author

olivernybroe commented Apr 5, 2021

@lulco Yes, so that problem could be fixed by a package named something like rector/rector-contracts.

However, the next problem is that the packages are not written in PHP 7.1, however rector/rector-prefixed is downgraded to 7.1, so we need a way to handle all the packages which are written in another version and use rector to downgrade them to 7.1 and have that as a separate package.
This might have to be rector/rector-laravel-prefixed and so on, and then some GitHub actions to do the work for us.

Another possible solution would be that rector prefixed always contains all the packages.

@lulco
Copy link
Contributor

lulco commented Apr 5, 2021

@olivernybroe hm, I forgot that PHP7.1 thing :) If there will be rector/rector-*-prefixed, imho there is no need for rector/rector-contracts.

Another solutions are 1) to write rector and packages directly in PHP 7.1 or 2) do not support this version at all

@olivernybroe
Copy link
Contributor Author

@lulco I don't think writing the packages in PHP 7.1 is a nice solution. It seems like something that will give other issues down the road 👍

As the prefixed rector already is bundled, I think it shouldn't matter that all the packages are pre-bundled into it. If people want lower file size, then don't use the prefixed bundle.

@lulco
Copy link
Contributor

lulco commented Apr 6, 2021

Well, for example I don’t want to use prefixed Rector but I have to because of conflicts with symfony packages used in Rector and my projects. And I also would like to have only Rector packages I need. No laravel, no symfony etc.

@olivernybroe
Copy link
Contributor Author

Hmm, yeah I guess the best solution for that would then be to "simply" have a rector/rector-*-prefixed for each of the packages then.

@lulco
Copy link
Contributor

lulco commented Apr 6, 2021

Yeah probably

@TomasVotruba
Copy link
Member

TomasVotruba commented Apr 24, 2021

First step towards decoupling #6174 by @sabbelasichon 👍

@TomasVotruba
Copy link
Member

TomasVotruba commented Apr 26, 2021

Thank you for your input, dicussion and points pro and against.

After few dicussions with active rule users, I've came to conclusion that priority is in simple Rector use with 1 package - downgraded and prefixed. Making users to downgrade their own package would require tremendeous effort from them. Let's keept it simple.

We might come back to this in the future, when it changes.

@sabbelasichon
Copy link
Contributor

I totally agree. I think the same.

@olivernybroe
Copy link
Contributor Author

Hi @TomasVotruba,

I just wanna understand completely here, does that mean you will drop rector/rector and only have rector/rector-prefixed in the future?

@TomasVotruba
Copy link
Member

TomasVotruba commented Apr 26, 2021

@olivernybroe Hi, I have not decided yet, but I think it's quite possible that it will happen. As PHPStan did in PHPStan 0.12 https://phpstan.org/blog/phpstan-0-12-released#phar-distribution-by-default

It would definitelly remove most of WTF on old and conflicting projects.

But we're still 2 minor version away and Rector needs to grow up a bit :)

TomasVotruba added a commit that referenced this issue Jun 20, 2024
rectorphp/rector-src@2dda748 [DX] Introduce set providers, to enable package + version based set registration (#5976)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants