Skip to content

Commit eec14b3

Browse files
authored
Merge pull request #5 from Siniliote/feat/update-dbal-orm
feat: Updating dependencies doctrine/dbal and doctrine/orm
2 parents 7072aec + fc94d0d commit eec14b3

File tree

8 files changed

+100
-26
lines changed

8 files changed

+100
-26
lines changed

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.0",
14-
"doctrine/orm": "^2.7",
15-
"webmozart/assert": "^1.9"
13+
"php": "^8",
14+
"doctrine/orm": "^2.7|^3.1",
15+
"doctrine/dbal": "^3.8|^4.0",
16+
"webmozart/assert": "^1.11"
1617
},
1718
"autoload": {
1819
"psr-4": {
@@ -21,9 +22,9 @@
2122
},
2223
"require-dev": {
2324
"phpunit/phpunit": "^9.4",
24-
"phpstan/phpstan": "^0.12.76",
25-
"squizlabs/php_codesniffer": "^3.5",
26-
"symfony/cache": "^5.4|^6.0"
25+
"phpstan/phpstan": "^1.11",
26+
"squizlabs/php_codesniffer": "^3.9",
27+
"symfony/cache": "^5.4|^6.0|^7.0"
2728
},
2829
"autoload-dev": {
2930
"psr-4": {

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
parameters:
22
level: max
3-
checkMissingIterableValueType: false
4-
checkGenericClassInNonGenericObjectType: false
53
paths:
64
- src/
75

86
ignoreErrors:
7+
- identifier: missingType.iterableValue
8+
- identifier: missingType.generics
99
# callable with array syntax is not inferred
1010
- '#.*function call_user_func expects callable.*#'

src/Doctrine/Types/CollectionValueObjectType.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\DBAL\Types\JsonType;
9+
use Doctrine\DBAL\Types\Type;
10+
use Doctrine\DBAL\Types\Types;
911
use Webmozart\Assert\Assert;
1012
use Yokai\DoctrineValueObject\CollectionValueObject;
1113

12-
final class CollectionValueObjectType extends JsonType
14+
final class CollectionValueObjectType extends Type
1315
{
1416
use ValueObjectType;
1517

18+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
19+
{
20+
/** @var JsonType $typeInherit */
21+
$typeInherit = $this->getType(Types::JSON);
22+
return $typeInherit->getSQLDeclaration($column, $platform);
23+
}
24+
1625
/**
1726
* @inheritdoc
1827
*/
@@ -33,15 +42,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
3342
Assert::isInstanceOf($value, $this->class);
3443
/** @var CollectionValueObject $value */
3544

36-
return parent::convertToDatabaseValue($value->toValue(), $platform);
45+
/** @var JsonType $typeInherit */
46+
$typeInherit = $this->getType(Types::JSON);
47+
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
3748
}
3849

3950
/**
4051
* @inheritdoc
4152
*/
4253
public function convertToPHPValue($value, AbstractPlatform $platform): ?CollectionValueObject
4354
{
44-
$value = parent::convertToPHPValue($value, $platform);
55+
/** @var JsonType $typeInherit */
56+
$typeInherit = $this->getType(Types::JSON);
57+
$value = $typeInherit->convertToPHPValue($value, $platform);
58+
4559
if ($value === null) {
4660
return null;
4761
}

src/Doctrine/Types/DateTimeValueObjectType.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@
77
use DateTimeImmutable;
88
use Doctrine\DBAL\Platforms\AbstractPlatform;
99
use Doctrine\DBAL\Types\DateTimeTzImmutableType;
10+
use Doctrine\DBAL\Types\Type;
11+
use Doctrine\DBAL\Types\Types;
1012
use Webmozart\Assert\Assert;
1113
use Yokai\DoctrineValueObject\DateTimeValueObject;
1214

13-
final class DateTimeValueObjectType extends DateTimeTzImmutableType
15+
final class DateTimeValueObjectType extends Type
1416
{
1517
use ValueObjectType;
1618

19+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
20+
{
21+
/** @var DateTimeTzImmutableType $typeInherit */
22+
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
23+
return $typeInherit->getSQLDeclaration($column, $platform);
24+
}
25+
1726
/**
1827
* @inheritdoc
1928
*/
@@ -34,15 +43,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
3443
Assert::isInstanceOf($value, $this->class);
3544
/** @var DateTimeValueObject $value */
3645

37-
return parent::convertToDatabaseValue($value->toValue(), $platform);
46+
/** @var DateTimeTzImmutableType $typeInherit */
47+
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
48+
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
3849
}
3950

4051
/**
4152
* @inheritdoc
4253
*/
43-
public function convertToPHPValue($value, AbstractPlatform $platform): ?DateTimeValueObject
54+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTimeValueObject
4455
{
45-
$value = parent::convertToPHPValue($value, $platform);
56+
/** @var DateTimeTzImmutableType $typeInherit */
57+
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
58+
$value = $typeInherit->convertToPHPValue($value, $platform);
59+
4660
if ($value === null) {
4761
return null;
4862
}

src/Doctrine/Types/IntegerValueObjectType.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\DBAL\Types\IntegerType;
9+
use Doctrine\DBAL\Types\Type;
10+
use Doctrine\DBAL\Types\Types;
911
use Webmozart\Assert\Assert;
1012
use Yokai\DoctrineValueObject\IntegerValueObject;
1113

12-
final class IntegerValueObjectType extends IntegerType
14+
final class IntegerValueObjectType extends Type
1315
{
1416
use ValueObjectType;
1517

18+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
19+
{
20+
/** @var IntegerType $typeInherit */
21+
$typeInherit = $this->getType(Types::INTEGER);
22+
return $typeInherit->getSQLDeclaration($column, $platform);
23+
}
24+
1625
/**
1726
* @inheritdoc
1827
*/
@@ -33,15 +42,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int
3342
Assert::isInstanceOf($value, $this->class);
3443
/** @var IntegerValueObject $value */
3544

36-
return parent::convertToPHPValue($value->toValue(), $platform);
45+
/** @var IntegerType $typeInherit */
46+
$typeInherit = $this->getType(Types::INTEGER);
47+
return $typeInherit->convertToPHPValue($value->toValue(), $platform);
3748
}
3849

3950
/**
4051
* @inheritdoc
4152
*/
4253
public function convertToPHPValue($value, AbstractPlatform $platform): ?IntegerValueObject
4354
{
44-
$value = parent::convertToPHPValue($value, $platform);
55+
/** @var IntegerType $typeInherit */
56+
$typeInherit = $this->getType(Types::INTEGER);
57+
$value = $typeInherit->convertToPHPValue($value, $platform);
58+
4559
if ($value === null) {
4660
return null;
4761
}

src/Doctrine/Types/ObjectValueObjectType.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\DBAL\Types\JsonType;
9+
use Doctrine\DBAL\Types\Type;
10+
use Doctrine\DBAL\Types\Types;
911
use Webmozart\Assert\Assert;
1012
use Yokai\DoctrineValueObject\ObjectValueObject;
1113

12-
final class ObjectValueObjectType extends JsonType
14+
final class ObjectValueObjectType extends Type
1315
{
1416
use ValueObjectType;
1517

18+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
19+
{
20+
/** @var JsonType $typeInherit */
21+
$typeInherit = $this->getType(Types::JSON);
22+
return $typeInherit->getSQLDeclaration($column, $platform);
23+
}
24+
1625
/**
1726
* @inheritdoc
1827
*/
@@ -33,15 +42,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
3342
Assert::isInstanceOf($value, $this->class);
3443
/** @var ObjectValueObject $value */
3544

36-
return parent::convertToDatabaseValue($value->toValue(), $platform);
45+
/** @var JsonType $typeInherit */
46+
$typeInherit = $this->getType(Types::JSON);
47+
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
3748
}
3849

3950
/**
4051
* @inheritdoc
4152
*/
4253
public function convertToPHPValue($value, AbstractPlatform $platform): ?ObjectValueObject
4354
{
44-
$value = parent::convertToPHPValue($value, $platform);
55+
/** @var JsonType $typeInherit */
56+
$typeInherit = $this->getType(Types::JSON);
57+
$value = $typeInherit->convertToPHPValue($value, $platform);
58+
4559
if ($value === null) {
4660
return null;
4761
}

src/Doctrine/Types/StringValueObjectType.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\DBAL\Types\StringType;
9+
use Doctrine\DBAL\Types\Type;
10+
use Doctrine\DBAL\Types\Types;
911
use Webmozart\Assert\Assert;
1012
use Yokai\DoctrineValueObject\StringValueObject;
1113

12-
final class StringValueObjectType extends StringType
14+
final class StringValueObjectType extends Type
1315
{
1416
use ValueObjectType;
1517

18+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
19+
{
20+
/** @var StringType $typeInherit */
21+
$typeInherit = $this->getType(Types::STRING);
22+
return $typeInherit->getSQLDeclaration($column, $platform);
23+
}
24+
1625
/**
1726
* @inheritdoc
1827
*/
@@ -24,7 +33,7 @@ public static function getSupportedValueObjectType(): string
2433
/**
2534
* @inheritdoc
2635
*/
27-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
36+
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
2837
{
2938
if ($value === null) {
3039
return null;
@@ -33,15 +42,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
3342
Assert::isInstanceOf($value, $this->class);
3443
/** @var StringValueObject $value */
3544

36-
return parent::convertToDatabaseValue($value->toValue(), $platform);
45+
/** @var StringType $typeInherit */
46+
$typeInherit = $this->getType(Types::STRING);
47+
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
3748
}
3849

3950
/**
4051
* @inheritdoc
4152
*/
4253
public function convertToPHPValue($value, AbstractPlatform $platform): ?StringValueObject
4354
{
44-
$value = parent::convertToPHPValue($value, $platform);
55+
/** @var StringType $typeInherit */
56+
$typeInherit = $this->getType(Types::STRING);
57+
$value = $typeInherit->convertToPHPValue($value, $platform);
58+
4559
if ($value === null) {
4660
return null;
4761
}

tests/EntityTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ private function manager(): EntityManager
106106

107107
// create entity manager with an sqlite in memory storage
108108
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__], true);
109-
$connection = DriverManager::getConnection(['url' => 'sqlite:///:memory:']);
109+
$connection = DriverManager::getConnection([
110+
'driver' => 'pdo_sqlite',
111+
'url' => 'sqlite:///:memory:'
112+
]);
110113
$entityManager = new EntityManager($connection, $config);
111114
// create schema
112115
(new SchemaTool($entityManager))

0 commit comments

Comments
 (0)