2

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.

Peter suib
  • 108
  • 2
  • 10
  • I'm having the same issue with 0.14.6 on one project, but not another. I have even copied a change between projects, but Rector only picks it up in one of them. Have you found a solution in the meanwhile? – Maurice Oct 18 '22 at 10:35
  • @Maurice I didn't find any solution – Peter suib Oct 19 '22 at 11:03

2 Answers2

5

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 :)

Lemitchv
  • 66
  • 1
0

Do you perhaps use PHPStan? It seems that the phpstan.neon config file is automatically used by Rector, whether you tell it to or not.

I did the following

  • remove phpstan.neon file from project root dir
  • run Rector again with the --clear-cache option. It doesn't seem to recognize the config change in phpstan.neon without it.

And now Rector suggests changes again.

It seems to have something to do with the scanFiles option in phpstan.neon. In our case it had an entry to to fix issues where PHPCS enforces the use of global constants in custom sniffs.

parameters:
    scanFiles:
        - vendor/squizlabs/php_codesniffer/src/Util/Tokens.php

I don't have further details yet. But perhaps this might help you out.

Maurice
  • 4,829
  • 7
  • 41
  • 50