From afb29f3b678c37daa66c7087b8e36a7eeceeb840 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Fri, 13 Aug 2021 22:13:11 +0200 Subject: [PATCH] Add return types (LSP compatible) --- src/Types/DayOfWeekType.php | 12 ++++++------ src/Types/DurationType.php | 10 +++++----- src/Types/InstantType.php | 12 ++++++------ src/Types/LocalDateTimeType.php | 10 +++++----- src/Types/LocalDateType.php | 10 +++++----- src/Types/LocalTimeType.php | 10 +++++----- src/Types/PeriodType.php | 10 +++++----- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Types/DayOfWeekType.php b/src/Types/DayOfWeekType.php index 23956ff..012ed63 100644 --- a/src/Types/DayOfWeekType.php +++ b/src/Types/DayOfWeekType.php @@ -17,17 +17,17 @@ */ final class DayOfWeekType extends Type { - public function getName() + public function getName(): string { return 'DayOfWeek'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getSmallIntTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int { if ($value === null) { return null; @@ -44,7 +44,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?DayOfWeek { if ($value === null) { return null; @@ -53,12 +53,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return DayOfWeek::of((int) $value); } - public function getBindingType() + public function getBindingType(): int { return ParameterType::INTEGER; } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/DurationType.php b/src/Types/DurationType.php index bcb3a57..a3475e0 100644 --- a/src/Types/DurationType.php +++ b/src/Types/DurationType.php @@ -16,12 +16,12 @@ */ final class DurationType extends Type { - public function getName() + public function getName(): string { return 'Duration'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { if (!isset($column['length'])) { $column['length'] = 64; @@ -30,7 +30,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform) return $platform->getVarcharTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -47,7 +47,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?Duration { if ($value === null) { return null; @@ -56,7 +56,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return Duration::parse((string) $value); } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/InstantType.php b/src/Types/InstantType.php index 67e8df9..8299257 100644 --- a/src/Types/InstantType.php +++ b/src/Types/InstantType.php @@ -17,17 +17,17 @@ */ final class InstantType extends Type { - public function getName() + public function getName(): string { return 'Instant'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getIntegerTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int { if ($value === null) { return null; @@ -44,7 +44,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?Instant { if ($value === null) { return null; @@ -53,12 +53,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return Instant::of((int) $value); } - public function getBindingType() + public function getBindingType(): int { return ParameterType::INTEGER; } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/LocalDateTimeType.php b/src/Types/LocalDateTimeType.php index 74598a0..8f888bb 100644 --- a/src/Types/LocalDateTimeType.php +++ b/src/Types/LocalDateTimeType.php @@ -16,17 +16,17 @@ */ final class LocalDateTimeType extends Type { - public function getName() + public function getName(): string { return 'LocalDateTime'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getDateTimeTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -49,7 +49,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?LocalDateTime { if ($value === null) { return null; @@ -60,7 +60,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return LocalDateTime::parse($value); } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/LocalDateType.php b/src/Types/LocalDateType.php index 5900c71..642ecb7 100644 --- a/src/Types/LocalDateType.php +++ b/src/Types/LocalDateType.php @@ -16,17 +16,17 @@ */ final class LocalDateType extends Type { - public function getName() + public function getName(): string { return 'LocalDate'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getDateTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -43,7 +43,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?LocalDate { if ($value === null) { return null; @@ -52,7 +52,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return LocalDate::parse((string) $value); } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/LocalTimeType.php b/src/Types/LocalTimeType.php index 32172e2..0fe593d 100644 --- a/src/Types/LocalTimeType.php +++ b/src/Types/LocalTimeType.php @@ -16,17 +16,17 @@ */ final class LocalTimeType extends Type { - public function getName() + public function getName(): string { return 'LocalTime'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getTimeTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -49,7 +49,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?LocalTime { if ($value === null) { return null; @@ -58,7 +58,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return LocalTime::parse((string) $value); } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Types/PeriodType.php b/src/Types/PeriodType.php index b8cf7da..153e856 100644 --- a/src/Types/PeriodType.php +++ b/src/Types/PeriodType.php @@ -16,12 +16,12 @@ */ final class PeriodType extends Type { - public function getName() + public function getName(): string { return 'Period'; } - public function getSQLDeclaration(array $column, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { if (!isset($column['length'])) { $column['length'] = 64; @@ -30,7 +30,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform) return $platform->getVarcharTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -47,7 +47,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) ); } - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?Period { if ($value === null) { return null; @@ -56,7 +56,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return Period::parse((string) $value); } - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; }