Skip to content

[TypeDeclaration][DeadCode] Skip class with Doctrine static function mapping (loadMetadata) in TypedPropertyFromAssignsRector and RemoveUnusedPrivatePropertyRector#8059

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-skip-entity
Jun 20, 2026
Merged

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Jun 20, 2026

Copy link
Copy Markdown
Member

Skip classes that use Doctrine static function mapping in TypedPropertyFromAssignsRector and RemoveUnusedPrivatePropertyRector.

Such classes map their fields in a loadMetadata() method instead of attributes/annotations, so the existing attribute/annotation-based skip does not catch them. Both rules now bail out when the class defines a loadMetadata() method.

Example

use Doctrine\ORM\Mapping\ClassMetadata;

final class Product
{
    private $name;

    public static function loadMetadata(ClassMetadata $metadata): void
    {
        $metadata->mapField([
            'fieldName' => 'name',
            'type' => 'string',
        ]);
    }
}

The $name property is Doctrine-mapped via loadMetadata(), so it is left untouched (no type added, not removed as unused).

…mapping (loadMetadata) in TypedPropertyFromAssignsRector and RemoveUnusedPrivatePropertyRector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant