Skip to content

Incorrect behavior of ReadOnlyPropertyRector with JMS serializer #9216

@buffcode

Description

@buffcode

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/6fae90ed-2fb2-489d-a1db-ea260aa06132

<?php

use JMS\Serializer\Annotation as JMS;

/**
 * This is a DTO for a third-party-published message, consumed by Symfony.
 **/
class AsyncMessage
{
    #[JMS\Type('string')]
    private string $value;

    public function getValue(): string
    {
        return $this->value;
    }
}

Responsible rules

  • ReadOnlyPropertyRector

Expected Behavior

JMS properties should not be marked as readonly.

As other whitelisted annotations in src/NodeManipulator/PropertyManipulator.php::ALLOWED_NOT_READONLY_CLASS_ANNOTATIONS exist, if the class or property uses any of the JMS\Serializer\Annotation\* annotations, the rector should refrain from adding the readonly flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions