mirror of
https://github.com/symfony/maker-bundle.git
synced 2026-03-23 23:42:10 +01:00
Use stricter DateTime type instead of DateTimeInterface for mutable datetime fields
This commit is contained in:
@@ -263,7 +263,7 @@ final class DoctrineHelper
|
||||
Types::BOOLEAN => 'bool',
|
||||
Types::INTEGER, Types::SMALLINT => 'int',
|
||||
Types::FLOAT => 'float',
|
||||
Types::DATETIME_MUTABLE, Types::DATETIMETZ_MUTABLE, Types::DATE_MUTABLE, Types::TIME_MUTABLE => '\\'.\DateTimeInterface::class,
|
||||
Types::DATETIME_MUTABLE, Types::DATETIMETZ_MUTABLE, Types::DATE_MUTABLE, Types::TIME_MUTABLE => '\\'.\DateTime::class,
|
||||
Types::DATETIME_IMMUTABLE, Types::DATETIMETZ_IMMUTABLE, Types::DATE_IMMUTABLE, Types::TIME_IMMUTABLE => '\\'.\DateTimeImmutable::class,
|
||||
Types::DATEINTERVAL => '\\'.\DateInterval::class,
|
||||
'object' => 'object',
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
@@ -13,20 +12,20 @@ class User
|
||||
#[ORM\Column()]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $createdAt = null;
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTime $createdAt = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
public function getCreatedAt(): ?\DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(?\DateTimeInterface $createdAt): static
|
||||
public function setCreatedAt(?\DateTime $createdAt): static
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user