Skip to content

Commit 6cbde91

Browse files
Merge branch '6.3' into 6.4
* 6.3: Fix DBAL 4 compatibility [Cache] Fix ArrayAdapter::freeze() return type Do not match request twice in HttpUtils
2 parents de84143 + 0428c76 commit 6cbde91

File tree

9 files changed

+30
-27
lines changed

9 files changed

+30
-27
lines changed

Form/DoctrineOrmTypeGuesser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function guessType(string $class, string $property): ?TypeGuess
6161
}
6262

6363
return match ($metadata->getTypeOfField($property)) {
64-
'array',
64+
'array', // DBAL < 4
6565
Types::SIMPLE_ARRAY => new TypeGuess(CollectionType::class, [], Guess::MEDIUM_CONFIDENCE),
6666
Types::BOOLEAN => new TypeGuess(CheckboxType::class, [], Guess::HIGH_CONFIDENCE),
6767
Types::DATETIME_MUTABLE,

Middleware/Debug/DBAL3/Statement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function __construct(
3535
string $sql,
3636
private ?Stopwatch $stopwatch = null,
3737
) {
38-
parent::__construct($statement);
39-
4038
$this->query = new Query($sql);
39+
40+
parent::__construct($statement);
4141
}
4242

4343
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool

Middleware/Debug/Driver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public function connect(array $params): ConnectionInterface
4141
$connection,
4242
$this->debugDataHolder,
4343
$this->stopwatch,
44-
$this->connectionName,
44+
$this->connectionName
4545
);
4646
}
4747

4848
return new Connection(
4949
$connection,
5050
$this->debugDataHolder,
5151
$this->stopwatch,
52-
$this->connectionName,
52+
$this->connectionName
5353
);
5454
}
5555
}

Middleware/Debug/Query.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function stop(): void
4545
}
4646
}
4747

48-
public function setParam(string|int $param, mixed &$variable, int $type): void
48+
public function setParam(string|int $param, mixed &$variable, ParameterType|int $type): void
4949
{
5050
// Numeric indexes start at 0 in profiler
5151
$idx = \is_int($param) ? $param - 1 : $param;
@@ -87,7 +87,7 @@ public function getParams(): array
8787
}
8888

8989
/**
90-
* @return array<ParameterType|int>
90+
* @return array<int, int|ParameterType>
9191
*/
9292
public function getTypes(): array
9393
{

PropertyInfo/DoctrineExtractor.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public function getTypes(string $class, string $property, array $context = []):
159159
break;
160160
case Type::BUILTIN_TYPE_ARRAY:
161161
switch ($typeOfField) {
162-
case 'array':
163-
case 'json_array':
162+
case 'array': // DBAL < 4
163+
case 'json_array': // DBAL < 3
164164
// return null if $enumType is set, because we can't determine if collectionKeyType is string or int
165165
if ($enumType) {
166166
return null;
@@ -257,7 +257,7 @@ private function getPhpType(string $doctrineType): ?string
257257
Types::BOOLEAN => Type::BUILTIN_TYPE_BOOL,
258258
Types::BLOB,
259259
Types::BINARY => Type::BUILTIN_TYPE_RESOURCE,
260-
'object',
260+
'object', // DBAL < 4
261261
Types::DATE_MUTABLE,
262262
Types::DATETIME_MUTABLE,
263263
Types::DATETIMETZ_MUTABLE,
@@ -268,9 +268,9 @@ private function getPhpType(string $doctrineType): ?string
268268
Types::DATETIMETZ_IMMUTABLE,
269269
Types::TIME_IMMUTABLE,
270270
Types::DATEINTERVAL => Type::BUILTIN_TYPE_OBJECT,
271-
'array',
272-
Types::SIMPLE_ARRAY,
273-
'json_array' => Type::BUILTIN_TYPE_ARRAY,
271+
'array', // DBAL < 4
272+
'json_array', // DBAL < 3
273+
Types::SIMPLE_ARRAY => Type::BUILTIN_TYPE_ARRAY,
274274
default => null,
275275
};
276276
}

Tests/Fixtures/Type/StringWrapperType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
class StringWrapperType extends StringType
1818
{
19-
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
19+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
2020
{
2121
return $value instanceof StringWrapper ? $value->getString() : null;
2222
}
2323

24-
public function convertToPHPValue($value, AbstractPlatform $platform): mixed
24+
public function convertToPHPValue($value, AbstractPlatform $platform): StringWrapper
2525
{
2626
return new StringWrapper($value);
2727
}

Tests/PropertyInfo/Fixtures/DoctrineFooType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
3232
return $platform->getClobTypeDeclarationSQL([]);
3333
}
3434

35-
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
35+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
3636
{
3737
if (null === $value) {
3838
return null;
@@ -44,7 +44,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixe
4444
return $foo->bar;
4545
}
4646

47-
public function convertToPHPValue($value, AbstractPlatform $platform): mixed
47+
public function convertToPHPValue($value, AbstractPlatform $platform): ?Foo
4848
{
4949
if (null === $value) {
5050
return null;

Tests/Types/UlidTypeTest.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
// DBAL 3 compatibility
2727
class_exists('Doctrine\DBAL\Platforms\SqlitePlatform');
2828

29+
// DBAL 3 compatibility
30+
class_exists('Doctrine\DBAL\Platforms\SqlitePlatform');
31+
2932
final class UlidTypeTest extends TestCase
3033
{
3134
private const DUMMY_ULID = '01EEDQEK6ZAZE93J8KG5B4MBJC';
@@ -84,25 +87,25 @@ public function testNotSupportedTypeConversionForDatabaseValue()
8487
{
8588
$this->expectException(ConversionException::class);
8689

87-
$this->type->convertToDatabaseValue(new \stdClass(), new SqlitePlatform());
90+
$this->type->convertToDatabaseValue(new \stdClass(), new SQLitePlatform());
8891
}
8992

9093
public function testNullConversionForDatabaseValue()
9194
{
92-
$this->assertNull($this->type->convertToDatabaseValue(null, new SqlitePlatform()));
95+
$this->assertNull($this->type->convertToDatabaseValue(null, new SQLitePlatform()));
9396
}
9497

9598
public function testUlidInterfaceConvertsToPHPValue()
9699
{
97100
$ulid = $this->createMock(AbstractUid::class);
98-
$actual = $this->type->convertToPHPValue($ulid, new SqlitePlatform());
101+
$actual = $this->type->convertToPHPValue($ulid, new SQLitePlatform());
99102

100103
$this->assertSame($ulid, $actual);
101104
}
102105

103106
public function testUlidConvertsToPHPValue()
104107
{
105-
$ulid = $this->type->convertToPHPValue(self::DUMMY_ULID, new SqlitePlatform());
108+
$ulid = $this->type->convertToPHPValue(self::DUMMY_ULID, new SQLitePlatform());
106109

107110
$this->assertInstanceOf(Ulid::class, $ulid);
108111
$this->assertEquals(self::DUMMY_ULID, $ulid->__toString());
@@ -112,19 +115,19 @@ public function testInvalidUlidConversionForPHPValue()
112115
{
113116
$this->expectException(ConversionException::class);
114117

115-
$this->type->convertToPHPValue('abcdefg', new SqlitePlatform());
118+
$this->type->convertToPHPValue('abcdefg', new SQLitePlatform());
116119
}
117120

118121
public function testNullConversionForPHPValue()
119122
{
120-
$this->assertNull($this->type->convertToPHPValue(null, new SqlitePlatform()));
123+
$this->assertNull($this->type->convertToPHPValue(null, new SQLitePlatform()));
121124
}
122125

123126
public function testReturnValueIfUlidForPHPValue()
124127
{
125128
$ulid = new Ulid();
126129

127-
$this->assertSame($ulid, $this->type->convertToPHPValue($ulid, new SqlitePlatform()));
130+
$this->assertSame($ulid, $this->type->convertToPHPValue($ulid, new SQLitePlatform()));
128131
}
129132

130133
public function testGetName()
@@ -150,6 +153,6 @@ public static function provideSqlDeclarations(): \Generator
150153

151154
public function testRequiresSQLCommentHint()
152155
{
153-
$this->assertTrue($this->type->requiresSQLCommentHint(new SqlitePlatform()));
156+
$this->assertTrue($this->type->requiresSQLCommentHint(new SQLitePlatform()));
154157
}
155158
}

Types/AbstractUidType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ private function throwInvalidType(mixed $value): never
105105
private function throwValueNotConvertible(mixed $value, \Throwable $previous): never
106106
{
107107
if (!class_exists(ValueNotConvertible::class)) {
108-
throw ConversionException::conversionFailed($value, $this->getName(), previous: $previous);
108+
throw ConversionException::conversionFailed($value, $this->getName(), $previous);
109109
}
110110

111-
throw ValueNotConvertible::new($value, $this->getName(), previous: $previous);
111+
throw ValueNotConvertible::new($value, $this->getName(), null, $previous);
112112
}
113113
}

0 commit comments

Comments
 (0)