Skip to content

Commit 9c22814

Browse files
authored
Revert "Merge pull request #11399 from ThomasLandauer/issue-11377" (#11415)
This reverts commit cbb6c89, reversing changes made to 9c56071.
1 parent e0e55dc commit 9c22814

File tree

2 files changed

+3
-107
lines changed

2 files changed

+3
-107
lines changed

src/Tools/SchemaValidator.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use function in_array;
4040
use function interface_exists;
4141
use function is_a;
42-
use function method_exists;
4342
use function sprintf;
4443

4544
/**
@@ -50,29 +49,11 @@
5049
class SchemaValidator
5150
{
5251
/**
53-
* Map built-in Doctrine DBAL 3 types to PHP types
54-
*/
55-
private const BUILTIN_TYPES_MAP_DBAL3 = [
56-
AsciiStringType::class => 'string',
57-
BigIntType::class => 'string',
58-
BooleanType::class => 'bool',
59-
DecimalType::class => 'string',
60-
FloatType::class => 'float',
61-
GuidType::class => 'string',
62-
IntegerType::class => 'int',
63-
JsonType::class => 'array',
64-
SimpleArrayType::class => 'array',
65-
SmallIntType::class => 'int',
66-
StringType::class => 'string',
67-
TextType::class => 'string',
68-
];
69-
70-
/**
71-
* Map built-in Doctrine DBAL 4+ types to PHP types
52+
* It maps built-in Doctrine types to PHP types
7253
*/
7354
private const BUILTIN_TYPES_MAP = [
7455
AsciiStringType::class => 'string',
75-
BigIntType::class => 'string|int',
56+
BigIntType::class => 'string',
7657
BooleanType::class => 'bool',
7758
DecimalType::class => 'string',
7859
FloatType::class => 'float',
@@ -455,10 +436,6 @@ private function findBuiltInType(Type $type): string|null
455436
{
456437
$typeName = $type::class;
457438

458-
if (method_exists(BigIntType::class, 'getName')) { // DBAL 3
459-
return self::BUILTIN_TYPES_MAP_DBAL3[$typeName] ?? null;
460-
} else { // DBAL 4+
461-
return self::BUILTIN_TYPES_MAP[$typeName] ?? null;
462-
}
439+
return self::BUILTIN_TYPES_MAP[$typeName] ?? null;
463440
}
464441
}

tests/Tests/ORM/Tools/SchemaValidatorTest.php

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Collection;
9-
use Doctrine\DBAL\Types\BigIntType;
10-
use Doctrine\DBAL\Types\Types;
119
use Doctrine\ORM\EntityManagerInterface;
1210
use Doctrine\ORM\Mapping\Column;
1311
use Doctrine\ORM\Mapping\DiscriminatorMap;
@@ -32,8 +30,6 @@
3230
use PHPUnit\Framework\Attributes\DataProvider;
3331
use PHPUnit\Framework\Attributes\Group;
3432

35-
use function method_exists;
36-
3733
class SchemaValidatorTest extends OrmTestCase
3834
{
3935
private EntityManagerInterface|null $em = null;
@@ -232,47 +228,6 @@ public function testInvalidAssociationTowardsMappedSuperclass(): void
232228
$ce,
233229
);
234230
}
235-
236-
public function testBigintMappedToStringInt(): void
237-
{
238-
$class = $this->em->getClassMetadata(BigintMappedToStringInt::class);
239-
$ce = $this->validator->validateClass($class);
240-
241-
$this->assertEquals([], $ce); // Same for DBAL 3 and 4+
242-
}
243-
244-
public function testBigintMappedToInt(): void
245-
{
246-
$class = $this->em->getClassMetadata(BigintMappedToInt::class);
247-
$ce = $this->validator->validateClass($class);
248-
249-
if (method_exists(BigIntType::class, 'getName')) { // DBAL 3
250-
$this->assertEquals(
251-
["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string' returned by the 'bigint' DBAL type."],
252-
$ce,
253-
);
254-
} else { // DBAL 4+
255-
$this->assertEquals(
256-
["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."],
257-
$ce,
258-
);
259-
}
260-
}
261-
262-
public function testBigintMappedToString(): void
263-
{
264-
$class = $this->em->getClassMetadata(BigintMappedToString::class);
265-
$ce = $this->validator->validateClass($class);
266-
267-
if (method_exists(BigIntType::class, 'getName')) { // DBAL 3
268-
$this->assertEquals([], $ce);
269-
} else { // DBAL 4+
270-
$this->assertEquals(
271-
["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToString#bigint' has the property type 'string' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."],
272-
$ce,
273-
);
274-
}
275-
}
276231
}
277232

278233
#[MappedSuperclass]
@@ -592,39 +547,3 @@ class InvalidMappedSuperClass
592547
#[ManyToMany(targetEntity: 'InvalidMappedSuperClass', mappedBy: 'invalid')]
593548
private $selfWhatever;
594549
}
595-
596-
#[Entity]
597-
class BigintMappedToStringInt
598-
{
599-
#[Id]
600-
#[Column]
601-
#[GeneratedValue]
602-
private int $id;
603-
604-
#[Column(type: Types::BIGINT)]
605-
private string|int $bigint;
606-
}
607-
608-
#[Entity]
609-
class BigintMappedToInt
610-
{
611-
#[Id]
612-
#[Column]
613-
#[GeneratedValue]
614-
private int $id;
615-
616-
#[Column(type: Types::BIGINT)]
617-
private int $bigint;
618-
}
619-
620-
#[Entity]
621-
class BigintMappedToString
622-
{
623-
#[Id]
624-
#[Column]
625-
#[GeneratedValue]
626-
private int $id;
627-
628-
#[Column(type: Types::BIGINT)]
629-
private string $bigint;
630-
}

0 commit comments

Comments
 (0)