From 601260ac004807d6c643f8fd3c914d4c6484d212 Mon Sep 17 00:00:00 2001 From: EK Date: Fri, 17 Mar 2017 04:50:33 +0300 Subject: [PATCH] Remove incompatibility between \DateTime and \DateTimeImmutable by using \DateTimeInterface instead. --- lib/Doctrine/DBAL/Types/DateTimeType.php | 4 ++-- lib/Doctrine/DBAL/Types/DateTimeTzType.php | 4 ++-- lib/Doctrine/DBAL/Types/DateType.php | 4 ++-- lib/Doctrine/DBAL/Types/TimeType.php | 4 ++-- lib/Doctrine/DBAL/Types/VarDateTimeType.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php index 83ea69e4eed..a1830dce40d 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -53,7 +53,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) return $value; } - if ($value instanceof \DateTime) { + if ($value instanceof \DateTimeInterface) { return $value->format($platform->getDateTimeFormatString()); } @@ -65,7 +65,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null || $value instanceof \DateTime) { + if ($value === null || $value instanceof \DateTimeInterface) { return $value; } diff --git a/lib/Doctrine/DBAL/Types/DateTimeTzType.php b/lib/Doctrine/DBAL/Types/DateTimeTzType.php index 527aed19d2d..e73bcc90744 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeTzType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeTzType.php @@ -71,7 +71,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) return $value; } - if ($value instanceof \DateTime) { + if ($value instanceof \DateTimeInterface) { return $value->format($platform->getDateTimeTzFormatString()); } @@ -83,7 +83,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null || $value instanceof \DateTime) { + if ($value === null || $value instanceof \DateTimeInterface) { return $value; } diff --git a/lib/Doctrine/DBAL/Types/DateType.php b/lib/Doctrine/DBAL/Types/DateType.php index a5642a598f4..e3ed6a9e71e 100644 --- a/lib/Doctrine/DBAL/Types/DateType.php +++ b/lib/Doctrine/DBAL/Types/DateType.php @@ -53,7 +53,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) return $value; } - if ($value instanceof \DateTime) { + if ($value instanceof \DateTimeInterface) { return $value->format($platform->getDateFormatString()); } @@ -65,7 +65,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null || $value instanceof \DateTime) { + if ($value === null || $value instanceof \DateTimeInterface) { return $value; } diff --git a/lib/Doctrine/DBAL/Types/TimeType.php b/lib/Doctrine/DBAL/Types/TimeType.php index 34533d6ea1e..639533fad5c 100644 --- a/lib/Doctrine/DBAL/Types/TimeType.php +++ b/lib/Doctrine/DBAL/Types/TimeType.php @@ -53,7 +53,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) return $value; } - if ($value instanceof \DateTime) { + if ($value instanceof \DateTimeInterface) { return $value->format($platform->getTimeFormatString()); } @@ -65,7 +65,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null || $value instanceof \DateTime) { + if ($value === null || $value instanceof \DateTimeInterface) { return $value; } diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/lib/Doctrine/DBAL/Types/VarDateTimeType.php index 5cf35f79583..14da6f17e24 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeType.php @@ -42,7 +42,7 @@ class VarDateTimeType extends DateTimeType */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null || $value instanceof \DateTime) { + if ($value === null || $value instanceof \DateTimeInterface) { return $value; }