neos / rector

Neos Rector Recipes for code migrations
6 stars 4 forks source link

Renamed/Moved Classes are not detected in php #46

Closed Jan3k3y closed 4 months ago

Jan3k3y commented 5 months ago

For example I got this exception while updating a project (DocsNeosIo) to Neos9:

Required class "Neos\ContentRepository\Migration\Transformations\AbstractTransformation" could not be loaded properly for reflection from "Neos\DocsNeosIo\ContentRepository\Transformations\UpdateHyphenTransformation"

And I know a fix for all classes will not be possible/overwhelming, but at least the most used ones should be fixed/commented by rector

dlubitz commented 4 months ago

https://github.com/neos/Neos.DocsNeosIo/blob/main/DistributionPackages/Neos.DocsNeosIo/Classes/ContentRepository/Transformations/UpdateHyphenTransformation.php

Actually there is already a migration which should remove the parent class and add a comment: https://github.com/neos/rector/blob/c0b44f776d99df7d1c2d8c698f36bfb00b4d76c0/config/set/contentrepository-90.php#L377-L382

dlubitz commented 4 months ago

I've tested it the migrations with NeosDocsIo and actually the class get removed:

24) DistributionPackages/Neos.DocsNeosIo/DistributionPackages/Neos.DocsNeosIo/Classes/ContentRepository/Transformations/UpdateHyphenTransformation.php:4

    ---------- begin diff ----------
@@ @@
 use Neos\ContentRepository\Domain\Model\NodeData;
 use Neos\ContentRepository\Migration\Transformations\AbstractTransformation;

-/**
- * Transformation to migrate existing title properties to use the soft hyphen instead of ||
- */
-class UpdateHyphenTransformation extends AbstractTransformation
+// TODO 9.0 migration: You need to convert your AbstractTransformation to an implementation of Neos\ContentRepository\NodeMigration\Transformation\TransformationFactoryInterface
+class UpdateHyphenTransformation
 {
     /**
      * @var string
    ----------- end diff -----------

Applied rules:
 * ContextGetFirstLevelNodeCacheRector
 * RemoveParentClassRector