diff --git a/src/Types/AsciiStringType.php b/src/Types/AsciiStringType.php index cd928eee336..edf977b4fde 100644 --- a/src/Types/AsciiStringType.php +++ b/src/Types/AsciiStringType.php @@ -21,4 +21,9 @@ public function getBindingType(): ParameterType { return ParameterType::ASCII; } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/src/Types/EnumType.php b/src/Types/EnumType.php index 489dc4b5c7d..acb2b212b2d 100644 --- a/src/Types/EnumType.php +++ b/src/Types/EnumType.php @@ -15,4 +15,9 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return $platform->getEnumDeclarationSQL($column); } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/src/Types/GuidType.php b/src/Types/GuidType.php index cc7cc5fc3bf..b4ea73ce6d7 100644 --- a/src/Types/GuidType.php +++ b/src/Types/GuidType.php @@ -18,4 +18,9 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return $platform->getGuidTypeDeclarationSQL($column); } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/src/Types/StringType.php b/src/Types/StringType.php index d3f92aaaa46..d1cdf1b2531 100644 --- a/src/Types/StringType.php +++ b/src/Types/StringType.php @@ -18,4 +18,9 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return $platform->getStringTypeDeclarationSQL($column); } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/src/Types/Type.php b/src/Types/Type.php index fb480ee4ebd..ea4d0ac8334 100644 --- a/src/Types/Type.php +++ b/src/Types/Type.php @@ -85,10 +85,7 @@ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform) * * @throws ConversionException */ - public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed - { - return $value; - } + abstract public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed; /** * Gets the SQL declaration snippet for a column of this type. diff --git a/tests/Functional/Schema/MySQL/PointType.php b/tests/Functional/Schema/MySQL/PointType.php index 7236903777a..eaa00b75a4b 100644 --- a/tests/Functional/Schema/MySQL/PointType.php +++ b/tests/Functional/Schema/MySQL/PointType.php @@ -24,4 +24,9 @@ public function getMappedDatabaseTypes(AbstractPlatform $platform): array { return ['point']; } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php index 2c4c5ae6646..78498064d7a 100644 --- a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php +++ b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php @@ -761,12 +761,11 @@ public function testPartitionTable(): void self::assertTrue($tableFinal->hasColumn('id')); self::assertTrue($tableFinal->hasColumn('foo')); - $partitionedTableCount = (int) ($this->connection->fetchOne( + self::assertSame(1, $this->connection->fetchOne( "select count(*) as count from pg_class where relname = 'partitioned_table' and relkind = 'p'", )); - self::assertSame(1, $partitionedTableCount); - $partitionsCount = (int) ($this->connection->fetchOne( + self::assertSame(1, $this->connection->fetchOne( <<<'SQL' select count(*) as count from pg_class parent @@ -777,7 +776,6 @@ public function testPartitionTable(): void where parent.relname = 'partitioned_table' and parent.relkind = 'p'; SQL, )); - self::assertSame(1, $partitionsCount); } /** @link https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PUBLIC */ @@ -796,4 +794,9 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return 'MyMoney'; } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } } diff --git a/tests/Platforms/AbstractPlatformTestCase.php b/tests/Platforms/AbstractPlatformTestCase.php index c8c698d85ee..3dd4e7af4df 100644 --- a/tests/Platforms/AbstractPlatformTestCase.php +++ b/tests/Platforms/AbstractPlatformTestCase.php @@ -119,6 +119,11 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return $platform->getDecimalTypeDeclarationSQL($column); } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } }; if (Type::hasType($type->getName())) { diff --git a/tests/Types/DateTest.php b/tests/Types/DateTest.php index 12476b05dd5..b79af51229b 100644 --- a/tests/Types/DateTest.php +++ b/tests/Types/DateTest.php @@ -33,6 +33,7 @@ public function testDateConvertsToPHPValue(): void public function testDateResetsNonDatePartsToZeroUnixTimeValues(): void { + /** @var DateTime $date */ $date = $this->type->convertToPHPValue('1985-09-01', $this->platform); self::assertEquals('00:00:00', $date->format('H:i:s')); @@ -42,10 +43,12 @@ public function testDateRestsSummerTimeAffection(): void { date_default_timezone_set('Europe/Berlin'); + /** @var DateTime $date */ $date = $this->type->convertToPHPValue('2009-08-01', $this->platform); self::assertEquals('00:00:00', $date->format('H:i:s')); self::assertEquals('2009-08-01', $date->format('Y-m-d')); + /** @var DateTime $date */ $date = $this->type->convertToPHPValue('2009-11-01', $this->platform); self::assertEquals('00:00:00', $date->format('H:i:s')); self::assertEquals('2009-11-01', $date->format('Y-m-d')); diff --git a/tests/Types/DateTimeTest.php b/tests/Types/DateTimeTest.php index f2d13739156..e795960bfbb 100644 --- a/tests/Types/DateTimeTest.php +++ b/tests/Types/DateTimeTest.php @@ -48,6 +48,7 @@ public function testConvertsNonMatchingFormatToPhpValueWithParser(): void { $date = '1985/09/01 10:10:10.12345'; + /** @var DateTime $actual */ $actual = $this->type->convertToPHPValue($date, $this->platform); self::assertEquals('1985-09-01 10:10:10', $actual->format('Y-m-d H:i:s')); diff --git a/tests/Types/TimeTest.php b/tests/Types/TimeTest.php index cbe8c50caaa..81b2506f3c6 100644 --- a/tests/Types/TimeTest.php +++ b/tests/Types/TimeTest.php @@ -27,6 +27,7 @@ public function testTimeConvertsToPHPValue(): void public function testDateFieldResetInPHPValue(): void { + /** @var DateTime $time */ $time = $this->type->convertToPHPValue('01:23:34', $this->platform); self::assertEquals('01:23:34', $time->format('H:i:s')); diff --git a/tests/Types/TypeWithConstructor.php b/tests/Types/TypeWithConstructor.php index d0b813fcbfa..b681bef7195 100644 --- a/tests/Types/TypeWithConstructor.php +++ b/tests/Types/TypeWithConstructor.php @@ -20,4 +20,9 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st { return ''; } + + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + { + return $value; + } }