Skip to content

Commit

Permalink
Add return types (LSP compatible)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Aug 13, 2021
1 parent f457d6b commit afb29f3
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions src/Types/DayOfWeekType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/DurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Types/InstantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/LocalDateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/LocalDateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/LocalTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/PeriodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit afb29f3

Please sign in to comment.