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

Upgrade a symfony 2.8 project #4873

Closed
bbouabou opened this issue Dec 13, 2020 · 3 comments
Closed

Upgrade a symfony 2.8 project #4873

bbouabou opened this issue Dec 13, 2020 · 3 comments

Comments

@bbouabou
Copy link

bbouabou commented Dec 13, 2020

Question

Hello,

I'm trying to upgrade a symfony 2.8 project to a least the LTS and if it's not too difficult maybe to version 5.2.

I tried to use the last version of rector-prefixed but it was not working, as suggested by @arnaud-fr here I instaled the version 0.8.52 but it's still not working, now I have this error :

error

If I clear cache I only have the first error, all the next errors are similar.

This is my rector.php file :

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    // here we can define, what sets of rules will be applied
    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::SETS, [
        SetList::SYMFONY_28, 
        // SetList::SYMFONY_30
    ]);

    // // set paths to directories with your code
    $parameters->set(Option::PATHS, [
        __DIR__ . '/app',
        __DIR__ . '/src',
    ]);
    $parameters->set(Option::AUTOLOAD_PATHS, [
        // autoload specific file
        __DIR__ . '/app/autoload.php',
    ]);
    // register single rule
    $services = $containerConfigurator->services();
    $services->set(TypedPropertyRector::class);
};

The project was running in php 7.1 in production but I'm actully running it in a php 7.2 container, I would like to also update to the lts version of php.

Am I missing something ?

Thanks for your help.

@TomasVotruba
Copy link
Member

TomasVotruba commented Dec 13, 2020

Hi,

thanks for detailed screenshots including configuration.
From a quick look, you're trying to process Symfony files. Those Symfony files probably use some magic, and should be rather part of vendor (as in Symfony 3, 4...).

Personally I'd exclude them and run Rector only on your own custom code. Somethign like:

  // // set paths to directories with your code
    $parameters->set(Option::PATHS, [
        __DIR__ . '/app/Controller',
        __DIR__ . '/src',
    ]);

    $parameters->set(Option::EXCLUDE_PATHS, [
	 	// here put files you want to exclude from paths above
        __DIR__ . '/app/Controller/SomeSymfonyClass.php',
    ]);

@bbouabou
Copy link
Author

Hi,

Thank you for your reply.

I actually tried to do that and I didn’t have errors but when I ran the process, it just says OK in green, I tried with all symfony version in my rector.php and it’s the same ...
The only way to get a diff was with setlist::CODE_QUALITY

Is it a normal behavior ?

Thanks.

@TomasVotruba
Copy link
Member

TomasVotruba commented Dec 25, 2020

It usually change some code, but it depends how you run Rector on what code.
Upgrading from Symfony 2.8 will take a long time, there are many blockers that you need to know of. Like PHP version with Symfony matrix, replacements of deprecated packages that don't support future PHP versions anymore, migrating from XML configs to PHP etc.

If you need fasten up the upgrade, you can contact us: https://getrector.org/contact
We handle private upgrades as a services and will save you some frustrating times.

TomasVotruba added a commit that referenced this issue Aug 28, 2023
rectorphp/rector-src@eac3d46 [ProcessAnalyzer] Remove unnecessary hasAttribute(origNode) on RectifiedAnalyzer (#4873)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants