rector icon indicating copy to clipboard operation
rector copied to clipboard

Incorrect behavior of TypedPropertyFromColumnTypeRector

Open bendavies opened this issue 3 years ago • 1 comments

Bug Report

The default value of nullable on Column is false, so $bar and $baz below should both be converted the same way, but $bar is incorrectly set as nullable.

Subject Details
Rector version 0.14.2
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.org/demo/58adab3d-a4a3-4583-8bb8-90e36135991f

<?php

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Foo
{
    #[ORM\Column(type: 'string')]
    private $bar;    
    
    #[ORM\Column(type: 'string', nullable: false)]
    private $baz;
}

Responsible rules

  • TypedPropertyFromColumnTypeRector

Expected Behavior

$bar is string, not ?string

bendavies avatar Sep 06 '22 16:09 bendavies

Except an #[ORM\Id] which can be auto, it will be nullable except assigned in constructor

samsonasik avatar Sep 06 '22 23:09 samsonasik

I am closing it as except ID column, it is expected change without set initialization in constructor.

samsonasik avatar Dec 15 '22 12:12 samsonasik