phpsymfonydoctrine-ormphp-8rector

Rector not finding anything to change (Converting Doctrine annotations to attributes)


As Doctrine seems to have completely removed annotations support in their latest updates, I am trying to convert the annotations in my entities to attributes using Rector.

I followed the (seemingly) simple official tutorial - I have the exact same rector.php contents, without the NetteSetList:

use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\SensiolabsSetList;
use Rector\Config\RectorConfig;

return function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
        SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
        SensiolabsSetList::FRAMEWORK_EXTRA_61,
    ]);
};

I run the test with vendor/bin/rector process src/Entity --dry-run --debug.

It does list every single entity in src/Entity, but does not detect any possible changes, when it should replace every doctrine annotation with attributes.


Solution

  • I had the same problem, and I solve it by changing the version of Php in composer.json as explained here: Configure Rector and using a simple Rule with symfony 6/php8

    Just need to change php version 7 to 8 "php": ">=7.2.5" to "php": "^8.0"

    I hope this help :)