rectorphp/rector-doctrine

Incorrect behavior of RemoveRedundantDefaultPropertyAnnotationValuesRector

mkrauser opened this issue · 2 comments

Moved here from rectorphp/rector#7034

Bug Report

A @JoinTable-Annotation is added, even if it is already present.

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

Minimal PHP Code Causing Issue

See https://getrector.org/demo/c057a4bc-9be7-4347-a4cd-f0d719e71c17

<?php

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 * @ORM\Table(name="test")
 */
class Test
{
    /**
     * @ORM\ManyToMany(targetEntity="Type", inversedBy="tests")
     * @ORM\JoinTable(
     *    name="objects_portal_type",
     *    joinColumns={@ORM\JoinColumn(name="test_id", referencedColumnName="id")},
     *    inverseJoinColumns={@ORM\JoinColumn(name="type_id", referencedColumnName="id")}
     * )
     * @var \Doctrine\Common\Collections\Collection<\Type>
     */
    private \Doctrine\Common\Collections\Collection $types;

    public function __construct()
    {
        $this->types = new ArrayCollection();
    }

}

Responsible rules

  • RemoveRedundantDefaultPropertyAnnotationValuesRector

Expected Behavior

Improve the existing annotation, but do not duplicate it

Also, the @JoinColumn-Annotation are missing in the added Annotation

duplicate of #64