rector icon indicating copy to clipboard operation
rector copied to clipboard

Missing behaviour of `DoctrineSetList::DOCTRINE_CODE_QUALITY`

Open mvhirsch opened this issue 3 years ago • 1 comments

Bug Report

Subject Details
Rector version 0.13.7
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.org/demo/5bc8005e-3298-4f48-9f81-fb97526e0ff2

<?php

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;

#[Entity]
class Entity
{
    #[JoinColumn(nullable: true)]
    private ?Reference $reference;
}

Responsible rules

  • MoveCurrentDateTimeDefaultInEntityToConstructorRector

  • RemoveRedundantDefaultClassAnnotationValuesRector

  • RemoveRedundantDefaultPropertyAnnotationValuesRector

Expected Behavior

rector successfully removes the nullable: true in #[JoinColumn] (since it's already default). But now the whole #[JoinColumn] isn't needed anymore and should be removed, shouldn't it?

/cc @OskarStark

mvhirsch avatar Jul 06 '22 06:07 mvhirsch

This behavior is out of scope of defined rules. They only remove default values, not classes without effect.

A new rule is needed to handle your case.

TomasVotruba avatar Jul 06 '22 09:07 TomasVotruba

Closing as answered.

TomasVotruba avatar Aug 17 '22 14:08 TomasVotruba

@mvhirsch if you like you can create this rule in the working time 👍🏻😃

OskarStark avatar Aug 18 '22 08:08 OskarStark

That would be great :clap: :slightly_smiling_face:

TomasVotruba avatar Aug 18 '22 08:08 TomasVotruba