Skip to content

[TypeDeclaration] Skip class with Doctrine static function mapping (loadMetadata) in TypedPropertyFromStrictConstructorRector#8060

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-skip-static-mapping-strict
Jun 20, 2026
Merged

[TypeDeclaration] Skip class with Doctrine static function mapping (loadMetadata) in TypedPropertyFromStrictConstructorRector#8060
TomasVotruba merged 1 commit into
mainfrom
tv-skip-static-mapping-strict

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Skip classes that use Doctrine static function mapping in TypedPropertyFromStrictConstructorRector.

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

Example

use Doctrine\ORM\Mapping\ClassMetadata;

final class Product
{
    private $name;

    public function __construct(string $name)
    {
        $this->name = $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).

Follow-up to #8059, which applied the same skip to TypedPropertyFromAssignsRector and RemoveUnusedPrivatePropertyRector. See also rectorphp/rector-doctrine#484.

…oadMetadata) in TypedPropertyFromStrictConstructorRector
@TomasVotruba TomasVotruba merged commit 755bb32 into main Jun 20, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the tv-skip-static-mapping-strict branch June 20, 2026 10:47
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