Bug Report
Hi!
The TypedPropertyFromColumnTypeRector rule is not taking into account the default value of the Column nullable property.
When the NullabilityColumnPropertyTypeResolver class resolves the value from the annotation, if the value is not configured (because it matches the default value), the resolver does not look at the annotation default value itself. Which result in a nullable property where it should not.
| Subject |
Details |
| Rector version |
last dev-main |
| Installed as |
composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/cf1b2f7a-8064-488a-b580-bf111aa26dd5
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
final class DemoFile
{
/**
* @var string $id
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
}
Responsible rules
TypedPropertyFromColumnTypeRector
Actual Behavior
@@ -14,5 +14,5 @@
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private $id;
+ private ?string $id = null;
}
Expected Behavior
@@ -14,5 +14,5 @@
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private $id;
+ private string $id = null;
}
Bug Report
Hi!
The
TypedPropertyFromColumnTypeRectorrule is not taking into account the default value of the Column nullable property.When the
NullabilityColumnPropertyTypeResolverclass resolves the value from the annotation, if the value is not configured (because it matches the default value), the resolver does not look at the annotation default value itself. Which result in a nullable property where it should not.Minimal PHP Code Causing Issue
See https://getrector.com/demo/cf1b2f7a-8064-488a-b580-bf111aa26dd5
Responsible rules
TypedPropertyFromColumnTypeRectorActual Behavior
Expected Behavior