mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-29 22:30:01 +02:00
Use DatetimeImmutable instead of DateTime wherever possible
This commit is contained in:
parent
eebc373734
commit
235d572f8c
39 changed files with 222 additions and 112 deletions
|
@ -156,9 +156,9 @@ class Currency extends AbstractStructuralDBElement
|
|||
protected Collection $pricedetails;
|
||||
|
||||
#[Groups(['currency:read'])]
|
||||
protected ?\DateTime $addedDate = null;
|
||||
protected ?\DateTimeImmutable $addedDate = null;
|
||||
#[Groups(['currency:read'])]
|
||||
protected ?\DateTime $lastModified = null;
|
||||
protected ?\DateTimeImmutable $lastModified = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -46,7 +46,7 @@ use App\Entity\Contracts\NamedElementInterface;
|
|||
use App\Entity\Contracts\TimeStampableInterface;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
@ -173,9 +173,9 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
#[ORM\PreUpdate]
|
||||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
$this->lastModified = new DateTimeImmutable('now');
|
||||
if (!$this->addedDate instanceof \DateTimeInterface) {
|
||||
$this->addedDate = new DateTime('now');
|
||||
$this->addedDate = new DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
if ($this->part instanceof Part) {
|
||||
|
|
|
@ -38,7 +38,7 @@ use App\Validator\Constraints\BigDecimal\BigDecimalPositive;
|
|||
use App\Validator\Constraints\Selectable;
|
||||
use Brick\Math\BigDecimal;
|
||||
use Brick\Math\RoundingMode;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
@ -141,9 +141,9 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
#[ORM\PreUpdate]
|
||||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
$this->lastModified = new DateTimeImmutable('now');
|
||||
if (!$this->addedDate instanceof \DateTimeInterface) {
|
||||
$this->addedDate = new DateTime('now');
|
||||
$this->addedDate = new DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
if ($this->orderdetail instanceof Orderdetail) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue