Skip to content

Commit 2f08d1c

Browse files
committed
fix: droctrine 4 compatability (resolves #84)
1 parent f92d162 commit 2f08d1c

35 files changed

+71
-55
lines changed

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
doctrine: ^3.5
2929
testbench: 8.*
3030
- laravel: 11.*
31-
doctrine: ^3.5
31+
doctrine: ^4.0
3232
testbench: 9.*
3333
exclude:
3434
- php: 8.0

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"require": {
1717
"php": "^8.0",
18-
"doctrine/dbal": "^2.6|^3.5",
18+
"doctrine/dbal": "^2.6|^3.5|^4.0",
1919
"illuminate/container": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
2020
"illuminate/database": "^6.0|^7.0|^8.79|^9.0|^10.0|^11.0",
2121
"illuminate/events": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",

src/PostgresqlEnhancedServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Tpetry\PostgresqlEnhanced\Types\IsmnType;
3434
use Tpetry\PostgresqlEnhanced\Types\Issn13Type;
3535
use Tpetry\PostgresqlEnhanced\Types\IssnType;
36+
use Tpetry\PostgresqlEnhanced\Types\LaravelType;
3637
use Tpetry\PostgresqlEnhanced\Types\LtreeType;
3738
use Tpetry\PostgresqlEnhanced\Types\NummultirangeType;
3839
use Tpetry\PostgresqlEnhanced\Types\NumrangeType;
@@ -105,7 +106,7 @@ public function register(): void
105106
protected function registerDoctrineTypes(): void
106107
{
107108
foreach ($this->doctrineTypes as $type) {
108-
/** @var Type $typeInstance */
109+
/** @var Type&LaravelType $typeInstance */
109110
$typeInstance = new $type();
110111

111112
if (!Type::hasType($typeInstance->getName())) {

src/Types/BaseType.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,31 @@
55
namespace Tpetry\PostgresqlEnhanced\Types;
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
89
use Doctrine\DBAL\Types\Type;
910

10-
abstract class BaseType extends Type
11+
abstract class BaseType extends Type implements LaravelType
1112
{
1213
/**
1314
* Gets an array of database types that map to this Doctrine type.
1415
*/
15-
public function getMappedDatabaseTypes(AbstractPlatform $platform)
16+
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
1617
{
17-
return match ($platform->getName()) {
18-
'pgsql', 'postgres', 'postgresql' => [$this->getSQLDeclaration([], $platform)],
18+
return match (true) {
19+
$platform instanceof PostgreSQLPlatform => [$this->getSQLDeclaration([], $platform)],
1920
default => [],
2021
};
2122
}
2223

2324
/**
2425
* Gets the name of this type.
2526
*/
26-
abstract public function getName();
27+
abstract public function getName(): string;
2728

2829
/**
2930
* Gets the SQL declaration snippet for a column of this type.
3031
*/
31-
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
32+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
3233
{
3334
return $this->getName();
3435
}

src/Types/BitType.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,34 @@
55
namespace Tpetry\PostgresqlEnhanced\Types;
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
89
use Doctrine\DBAL\Types\StringType;
910

10-
class BitType extends StringType
11+
class BitType extends StringType implements LaravelType
1112
{
1213
/**
1314
* Gets an array of database types that map to this Doctrine type.
1415
*/
15-
public function getMappedDatabaseTypes(AbstractPlatform $platform)
16+
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
1617
{
17-
return match ($platform->getName()) {
18-
'pgsql', 'postgres', 'postgresql' => [$this->getName()],
18+
return match (true) {
19+
$platform instanceof PostgreSQLPlatform => [$this->getName()],
1920
default => [],
2021
};
2122
}
2223

2324
/**
2425
* Gets the name of this type.
2526
*/
26-
public function getName()
27+
public function getName(): string
2728
{
2829
return 'bit';
2930
}
3031

3132
/**
3233
* Gets the SQL declaration snippet for a column of this type.
3334
*/
34-
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
35+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
3536
{
3637
return "bit({$column['length']})";
3738
}

src/Types/CidrType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CidrType extends BaseType
99
/**
1010
* Gets the name of this type.
1111
*/
12-
public function getName()
12+
public function getName(): string
1313
{
1414
return 'cidr';
1515
}

src/Types/CitextType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CitextType extends BaseType
99
/**
1010
* Gets the name of this type.
1111
*/
12-
public function getName()
12+
public function getName(): string
1313
{
1414
return 'citext';
1515
}

src/Types/DatemultirangeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DatemultirangeType extends BaseType
99
/**
1010
* Gets the name of this type.
1111
*/
12-
public function getName()
12+
public function getName(): string
1313
{
1414
return 'datemultirange';
1515
}

src/Types/DaterangeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DaterangeType extends BaseType
99
/**
1010
* Gets the name of this type.
1111
*/
12-
public function getName()
12+
public function getName(): string
1313
{
1414
return 'daterange';
1515
}

src/Types/Ean13Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Ean13Type extends BaseType
99
/**
1010
* Gets the name of this type.
1111
*/
12-
public function getName()
12+
public function getName(): string
1313
{
1414
return 'ean13';
1515
}

0 commit comments

Comments
 (0)