Unexpected refractoring of nullable datetime field
Closed this issue · 4 comments
alexander-schranz commented
When running rector with the doctrine exension:
$containerConfigurator->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);
1) src/Cashback/Domain/Model/CashbackClaim.php:57
---------- begin diff ----------
@@ @@
/**
* @ORM\Column(type="datetime", nullable=true)
*/
- private ?DateTimeInterface $orderDetailsOrderDate = null;
+ private ?DateTimeInterface $orderDetailsOrderDate;
/**
* @ORM\Column(length="256")
@@ @@
@@ @@
{
$uuid = Uuid::uuid4();
$this->entityId = $uuid->toString();
+ $this->orderDetailsOrderDate = new \DateTime(null);
}
The result is unexpected as it did add:
$this->orderDetailsOrderDate = new \DateTime(null);
Which should just stay as:
private ?DateTimeInterface $orderDetailsOrderDate = null;
TomasVotruba commented
Thank you for your report!
We'll need an isolated failing demo link from: http://getrector.org/demo,
that way we can reproduce the bug.
alexander-schranz commented
@TomasVotruba Oh thanks for the fast response, here is the reproducable: https://getrector.org/demo/1ec43f79-82a0-6654-ab32-db938ba1d153
TomasVotruba commented
Thanks. The next step is to identify which rule should behave differently and what you expect to output.
Could you send the failing test fixture to the picked rule?
alexander-schranz commented
Its the MoveCurrentDateTimeDefaultInEntityToConstructorRector
:
See as a possible fix: #45