diff --git a/UPGRADE.md b/UPGRADE.md index bf07938365..776b749298 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,16 @@ +# Upgrade to 2.10 + +## Deprecated `Type::*` constants + +The constants for built-in types have been moved from `Doctrine\DBAL\Types\Type` to a separate class `Doctrine\DBAL\Types\DefaultTypes`. + +Some of the constants were renamed: +* `TARRAY`-> `ARRAY` +* `DATE` -> `DATE_MUTABLE` +* `DATETIME` -> `DATETIME_MUTABLE` +* `DATETIMETZ` -> `DATETIMETZ_MUTABLE` +* `TIME` -> `TIME_MUTABLE` + # Upgrade to 2.9 ## Deprecated `Configuration::getFilterSchemaAssetsExpression()`, `::setFilterSchemaAssetsExpression()` and `AbstractSchemaManager::getFilterSchemaAssetsExpression()`. diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 605122115d..37988b63b3 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use function array_merge; use function count; @@ -97,7 +98,7 @@ public function initializeDoctrineTypeMappings() */ public function isCommentedDoctrineType(Type $doctrineType) { - if ($doctrineType->getName() === Type::BOOLEAN) { + if ($doctrineType->getName() === DefaultTypes::BOOLEAN) { // We require a commented boolean type in order to distinguish between boolean and smallint // as both (have to) map to the same native type. return true; diff --git a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php index 25420a0476..5341ad8f2d 100644 --- a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php +++ b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; /** * Provides the behavior, features and SQL dialect of the MariaDB 10.2 (10.2.7 GA) database platform. @@ -36,6 +36,6 @@ protected function initializeDoctrineTypeMappings() : void { parent::initializeDoctrineTypeMappings(); - $this->doctrineTypeMapping['json'] = Type::JSON; + $this->doctrineTypeMapping['json'] = DefaultTypes::JSON; } } diff --git a/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php b/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php index 71ef6ca96c..1735bf50d0 100644 --- a/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php +++ b/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\TableDiff; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; /** * Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform. @@ -66,6 +66,6 @@ protected function initializeDoctrineTypeMappings() { parent::initializeDoctrineTypeMappings(); - $this->doctrineTypeMapping['json'] = Type::JSON; + $this->doctrineTypeMapping['json'] = DefaultTypes::JSON; } } diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php index b302c0ceb8..505e30c87e 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; use function sprintf; /** @@ -53,7 +53,7 @@ protected function initializeDoctrineTypeMappings() { parent::initializeDoctrineTypeMappings(); - $this->doctrineTypeMapping['json'] = Type::JSON; + $this->doctrineTypeMapping['json'] = DefaultTypes::JSON; } /** diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php index 9db0ecbbd2..203baafba3 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; /** * Provides the behavior, features and SQL dialect of the PostgreSQL 9.4 database platform. @@ -36,6 +36,6 @@ protected function initializeDoctrineTypeMappings() { parent::initializeDoctrineTypeMappings(); - $this->doctrineTypeMapping['jsonb'] = Type::JSON; + $this->doctrineTypeMapping['jsonb'] = DefaultTypes::JSON; } } diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index 168e74ea87..2721f5d64e 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use const CASE_LOWER; use function array_change_key_case; @@ -456,7 +457,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $column->setPlatformOption('collation', $tableColumn['collation']); } - if (in_array($column->getType()->getName(), [Type::JSON_ARRAY, Type::JSON], true)) { + if (in_array($column->getType()->getName(), [DefaultTypes::JSON_ARRAY, DefaultTypes::JSON], true)) { $column->setPlatformOption('jsonb', $jsonb); } diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index 32d642365b..c012e25c68 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer; use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use RuntimeException; use function array_merge; @@ -240,12 +241,12 @@ private function getFederationTypeDefaultValue() $federationType = Type::getType($this->shardManager->getDistributionType()); switch ($federationType->getName()) { - case Type::GUID: + case DefaultTypes::GUID: $defaultValue = '00000000-0000-0000-0000-000000000000'; break; - case Type::INTEGER: - case Type::SMALLINT: - case Type::BIGINT: + case DefaultTypes::INTEGER: + case DefaultTypes::SMALLINT: + case DefaultTypes::BIGINT: $defaultValue = '0'; break; default: diff --git a/lib/Doctrine/DBAL/Types/ArrayType.php b/lib/Doctrine/DBAL/Types/ArrayType.php index 9bb8e578b2..5d242a2857 100644 --- a/lib/Doctrine/DBAL/Types/ArrayType.php +++ b/lib/Doctrine/DBAL/Types/ArrayType.php @@ -59,7 +59,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getName() { - return Type::TARRAY; + return DefaultTypes::ARRAY; } /** diff --git a/lib/Doctrine/DBAL/Types/BigIntType.php b/lib/Doctrine/DBAL/Types/BigIntType.php index 1d320d624d..50222741be 100644 --- a/lib/Doctrine/DBAL/Types/BigIntType.php +++ b/lib/Doctrine/DBAL/Types/BigIntType.php @@ -15,7 +15,7 @@ class BigIntType extends Type implements PhpIntegerMappingType */ public function getName() { - return Type::BIGINT; + return DefaultTypes::BIGINT; } /** diff --git a/lib/Doctrine/DBAL/Types/BinaryType.php b/lib/Doctrine/DBAL/Types/BinaryType.php index 14362e840a..3c1bc8f509 100644 --- a/lib/Doctrine/DBAL/Types/BinaryType.php +++ b/lib/Doctrine/DBAL/Types/BinaryType.php @@ -40,7 +40,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) } if (! is_resource($value)) { - throw ConversionException::conversionFailed($value, self::BINARY); + throw ConversionException::conversionFailed($value, DefaultTypes::BINARY); } return $value; @@ -51,7 +51,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getName() { - return Type::BINARY; + return DefaultTypes::BINARY; } /** diff --git a/lib/Doctrine/DBAL/Types/BlobType.php b/lib/Doctrine/DBAL/Types/BlobType.php index c309f0f063..995c028111 100644 --- a/lib/Doctrine/DBAL/Types/BlobType.php +++ b/lib/Doctrine/DBAL/Types/BlobType.php @@ -40,7 +40,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) } if (! is_resource($value)) { - throw ConversionException::conversionFailed($value, self::BLOB); + throw ConversionException::conversionFailed($value, DefaultTypes::BLOB); } return $value; @@ -51,7 +51,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getName() { - return Type::BLOB; + return DefaultTypes::BLOB; } /** diff --git a/lib/Doctrine/DBAL/Types/BooleanType.php b/lib/Doctrine/DBAL/Types/BooleanType.php index 976f00e1fb..6b6cdb2875 100644 --- a/lib/Doctrine/DBAL/Types/BooleanType.php +++ b/lib/Doctrine/DBAL/Types/BooleanType.php @@ -39,7 +39,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getName() { - return Type::BOOLEAN; + return DefaultTypes::BOOLEAN; } /** diff --git a/lib/Doctrine/DBAL/Types/DateImmutableType.php b/lib/Doctrine/DBAL/Types/DateImmutableType.php index 196fc88c7b..27e7fea819 100644 --- a/lib/Doctrine/DBAL/Types/DateImmutableType.php +++ b/lib/Doctrine/DBAL/Types/DateImmutableType.php @@ -15,7 +15,7 @@ class DateImmutableType extends DateType */ public function getName() { - return Type::DATE_IMMUTABLE; + return DefaultTypes::DATE_IMMUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DateIntervalType.php b/lib/Doctrine/DBAL/Types/DateIntervalType.php index 30e61c9eaa..f8bb9194cb 100644 --- a/lib/Doctrine/DBAL/Types/DateIntervalType.php +++ b/lib/Doctrine/DBAL/Types/DateIntervalType.php @@ -19,7 +19,7 @@ class DateIntervalType extends Type */ public function getName() { - return Type::DATEINTERVAL; + return DefaultTypes::DATEINTERVAL; } /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php index fdda50faa4..f921e1e072 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php @@ -16,7 +16,7 @@ class DateTimeImmutableType extends DateTimeType */ public function getName() { - return Type::DATETIME_IMMUTABLE; + return DefaultTypes::DATETIME_IMMUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php index 962d9d38da..418ddbc855 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -17,7 +17,7 @@ class DateTimeType extends Type implements PhpDateTimeMappingType */ public function getName() { - return Type::DATETIME; + return DefaultTypes::DATETIME_MUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php index 253c02e002..5453a9ed69 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php @@ -15,7 +15,7 @@ class DateTimeTzImmutableType extends DateTimeTzType */ public function getName() { - return Type::DATETIMETZ_IMMUTABLE; + return DefaultTypes::DATETIMETZ_IMMUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeTzType.php b/lib/Doctrine/DBAL/Types/DateTimeTzType.php index 0b78720ec3..547bca4ace 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeTzType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeTzType.php @@ -29,7 +29,7 @@ class DateTimeTzType extends Type implements PhpDateTimeMappingType */ public function getName() { - return Type::DATETIMETZ; + return DefaultTypes::DATETIMETZ_MUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DateType.php b/lib/Doctrine/DBAL/Types/DateType.php index b5ad5356f6..012bb21eb5 100644 --- a/lib/Doctrine/DBAL/Types/DateType.php +++ b/lib/Doctrine/DBAL/Types/DateType.php @@ -16,7 +16,7 @@ class DateType extends Type */ public function getName() { - return Type::DATE; + return DefaultTypes::DATE_MUTABLE; } /** diff --git a/lib/Doctrine/DBAL/Types/DecimalType.php b/lib/Doctrine/DBAL/Types/DecimalType.php index 318cb2476b..346eef2e01 100644 --- a/lib/Doctrine/DBAL/Types/DecimalType.php +++ b/lib/Doctrine/DBAL/Types/DecimalType.php @@ -14,7 +14,7 @@ class DecimalType extends Type */ public function getName() { - return Type::DECIMAL; + return DefaultTypes::DECIMAL; } /** diff --git a/lib/Doctrine/DBAL/Types/DefaultTypes.php b/lib/Doctrine/DBAL/Types/DefaultTypes.php new file mode 100644 index 0000000000..4a798aed00 --- /dev/null +++ b/lib/Doctrine/DBAL/Types/DefaultTypes.php @@ -0,0 +1,43 @@ + ArrayType::class, - self::SIMPLE_ARRAY => SimpleArrayType::class, - self::JSON_ARRAY => JsonArrayType::class, - self::JSON => JsonType::class, - self::OBJECT => ObjectType::class, - self::BOOLEAN => BooleanType::class, - self::INTEGER => IntegerType::class, - self::SMALLINT => SmallIntType::class, - self::BIGINT => BigIntType::class, - self::STRING => StringType::class, - self::TEXT => TextType::class, - self::DATETIME => DateTimeType::class, - self::DATETIME_IMMUTABLE => DateTimeImmutableType::class, - self::DATETIMETZ => DateTimeTzType::class, - self::DATETIMETZ_IMMUTABLE => DateTimeTzImmutableType::class, - self::DATE => DateType::class, - self::DATE_IMMUTABLE => DateImmutableType::class, - self::TIME => TimeType::class, - self::TIME_IMMUTABLE => TimeImmutableType::class, - self::DECIMAL => DecimalType::class, - self::FLOAT => FloatType::class, - self::BINARY => BinaryType::class, - self::BLOB => BlobType::class, - self::GUID => GuidType::class, - self::DATEINTERVAL => DateIntervalType::class, + DefaultTypes::ARRAY => ArrayType::class, + DefaultTypes::BIGINT => BigIntType::class, + DefaultTypes::BINARY => BinaryType::class, + DefaultTypes::BLOB => BlobType::class, + DefaultTypes::BOOLEAN => BooleanType::class, + DefaultTypes::DATE_MUTABLE => DateType::class, + DefaultTypes::DATE_IMMUTABLE => DateImmutableType::class, + DefaultTypes::DATEINTERVAL => DateIntervalType::class, + DefaultTypes::DATETIME_MUTABLE => DateTimeType::class, + DefaultTypes::DATETIME_IMMUTABLE => DateTimeImmutableType::class, + DefaultTypes::DATETIMETZ_MUTABLE => DateTimeTzType::class, + DefaultTypes::DATETIMETZ_IMMUTABLE => DateTimeTzImmutableType::class, + DefaultTypes::DECIMAL => DecimalType::class, + DefaultTypes::FLOAT => FloatType::class, + DefaultTypes::GUID => GuidType::class, + DefaultTypes::INTEGER => IntegerType::class, + DefaultTypes::JSON => JsonType::class, + DefaultTypes::JSON_ARRAY => JsonArrayType::class, + DefaultTypes::OBJECT => ObjectType::class, + DefaultTypes::SIMPLE_ARRAY => SimpleArrayType::class, + DefaultTypes::SMALLINT => SmallIntType::class, + DefaultTypes::STRING => StringType::class, + DefaultTypes::TEXT => TextType::class, + DefaultTypes::TIME_MUTABLE => TimeType::class, + DefaultTypes::TIME_IMMUTABLE => TimeImmutableType::class, ]; /** diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php index 6636f53a5b..91ed66d914 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php @@ -16,7 +16,7 @@ class VarDateTimeImmutableType extends VarDateTimeType */ public function getName() { - return Type::DATETIME_IMMUTABLE; + return DefaultTypes::DATETIME_IMMUTABLE; } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php index b9d03d5e66..e6f0f0c132 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\Tests\DbalFunctionalTestCase; use Error; use Exception; @@ -252,7 +252,7 @@ public function testTransactionalReturnValue() public function testQuote() { self::assertEquals( - $this->connection->quote('foo', Type::STRING), + $this->connection->quote('foo', DefaultTypes::STRING), $this->connection->quote('foo', ParameterType::STRING) ); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 9f6fcbfd75..26cc4ca639 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -13,7 +13,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Statement; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\Tests\DbalFunctionalTestCase; use const CASE_LOWER; use const PHP_EOL; @@ -222,7 +222,11 @@ public function testFetchAllWithTypes() $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $data = $this->connection->fetchAll($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]); + $data = $this->connection->fetchAll( + $sql, + [1, $datetime], + [ParameterType::STRING, DefaultTypes::DATETIME_MUTABLE] + ); self::assertCount(1, $data); @@ -292,7 +296,11 @@ public function testFetchAssocWithTypes() $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $row = $this->connection->fetchAssoc($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]); + $row = $this->connection->fetchAssoc( + $sql, + [1, $datetime], + [ParameterType::STRING, DefaultTypes::DATETIME_MUTABLE] + ); self::assertNotFalse($row); @@ -333,7 +341,11 @@ public function testFetchArrayWithTypes() $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $row = $this->connection->fetchArray($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]); + $row = $this->connection->fetchArray( + $sql, + [1, $datetime], + [ParameterType::STRING, DefaultTypes::DATETIME_MUTABLE] + ); self::assertNotFalse($row); @@ -378,7 +390,12 @@ public function testFetchColumnWithTypes() $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $column = $this->connection->fetchColumn($sql, [1, $datetime], 1, [ParameterType::STRING, Type::DATETIME]); + $column = $this->connection->fetchColumn( + $sql, + [1, $datetime], + 1, + [ParameterType::STRING, DefaultTypes::DATETIME_MUTABLE] + ); self::assertNotFalse($column); @@ -410,7 +427,7 @@ public function testExecuteQueryBindDateTimeType() $stmt = $this->connection->executeQuery( $sql, [1 => new DateTime('2010-01-01 10:10:10')], - [1 => Type::DATETIME] + [1 => DefaultTypes::DATETIME_MUTABLE] ); self::assertEquals(1, $stmt->fetchColumn()); @@ -431,14 +448,14 @@ public function testExecuteUpdateBindDateTimeType() ], [ 1 => ParameterType::INTEGER, 2 => ParameterType::STRING, - 3 => Type::DATETIME, + 3 => DefaultTypes::DATETIME_MUTABLE, ]); self::assertEquals(1, $affectedRows); self::assertEquals(1, $this->connection->executeQuery( 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?', [1 => $datetime], - [1 => Type::DATETIME] + [1 => DefaultTypes::DATETIME_MUTABLE] )->fetchColumn()); } @@ -449,7 +466,7 @@ public function testPrepareQueryBindValueDateTimeType() { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; $stmt = $this->connection->prepare($sql); - $stmt->bindValue(1, new DateTime('2010-01-01 10:10:10'), Type::DATETIME); + $stmt->bindValue(1, new DateTime('2010-01-01 10:10:10'), DefaultTypes::DATETIME_MUTABLE); $stmt->execute(); self::assertEquals(1, $stmt->fetchColumn()); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index b1669e345f..bead3f1343 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\Types\MySqlPointType; use function implode; @@ -347,7 +348,7 @@ public function testJsonColumnType() : void $columns = $this->schemaManager->listTableColumns('test_mysql_json'); - self::assertSame(Type::JSON, $columns['col_json']->getType()->getName()); + self::assertSame(DefaultTypes::JSON, $columns['col_json']->getType()->getName()); } public function testColumnDefaultCurrentTimestamp() : void diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php index 33d1131ead..7d186caee3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php @@ -5,7 +5,7 @@ use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\BinaryType; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\Tests\TestUtil; use function array_map; @@ -227,7 +227,7 @@ public function testListTableColumnsSameTableNamesInDifferentSchemas() $this->schemaManager->dropAndCreateTable($table); $otherTable = new Table($table->getName()); - $otherTable->addColumn('id', Type::STRING); + $otherTable->addColumn('id', DefaultTypes::STRING); TestUtil::getTempConnection()->getSchemaManager()->dropAndCreateTable($otherTable); $columns = $this->schemaManager->listTableColumns($table->getName(), $this->connection->getUsername()); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index e007eabda2..f1c79a27df 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\DecimalType; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use function array_map; use function array_pop; @@ -410,8 +411,8 @@ public function testJsonbColumn(string $type) : void public function jsonbColumnTypeProvider() : array { return [ - [Type::JSON], - [Type::JSON_ARRAY], + [DefaultTypes::JSON], + [DefaultTypes::JSON_ARRAY], ]; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 659e6d8dff..1f25126bbe 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\BlobType; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use SQLite3; use function array_map; @@ -205,8 +206,8 @@ public function testListTableColumnsWithWhitespacesInTypeDeclarations() self::assertArrayHasKey('foo', $columns); self::assertArrayHasKey('bar', $columns); - self::assertSame(Type::getType(Type::STRING), $columns['foo']->getType()); - self::assertSame(Type::getType(Type::TEXT), $columns['bar']->getType()); + self::assertSame(Type::getType(DefaultTypes::STRING), $columns['foo']->getType()); + self::assertSame(Type::getType(DefaultTypes::TEXT), $columns['bar']->getType()); self::assertSame(64, $columns['foo']->getLength()); self::assertSame(100, $columns['bar']->getLength()); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index ce2b7df42a..e85b90610e 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; class DB2PlatformTest extends AbstractPlatformTestCase @@ -279,7 +280,7 @@ public function getIsCommentedDoctrineType() { $data = parent::getIsCommentedDoctrineType(); - $data[Type::BOOLEAN] = [Type::getType(Type::BOOLEAN), true]; + $data[DefaultTypes::BOOLEAN] = [Type::getType(DefaultTypes::BOOLEAN), true]; return $data; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php index 7171ad714d..3bb7c24669 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\MariaDb1027Platform; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase { @@ -33,7 +33,7 @@ public function testReturnsJsonTypeDeclarationSQL() : void public function testInitializesJsonTypeMapping() : void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); - self::assertSame(Type::JSON, $this->platform->getDoctrineTypeMapping('json')); + self::assertSame(DefaultTypes::JSON, $this->platform->getDoctrineTypeMapping('json')); } /** diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php index 52d7ca0708..6ea3bc8b55 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\MySQL57Platform; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase { @@ -28,7 +28,7 @@ public function testReturnsJsonTypeDeclarationSQL() public function testInitializesJsonTypeMapping() { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); - self::assertSame(Type::JSON, $this->platform->getDoctrineTypeMapping('json')); + self::assertSame(DefaultTypes::JSON, $this->platform->getDoctrineTypeMapping('json')); } /** diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php index fb36beb334..63beb7d9cd 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\PostgreSQL92Platform; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; class PostgreSQL92PlatformTest extends AbstractPostgreSqlPlatformTestCase { @@ -55,7 +55,7 @@ public function testReturnsSmallIntTypeDeclarationSQL() public function testInitializesJsonTypeMapping() { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); - self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('json')); + self::assertEquals(DefaultTypes::JSON, $this->platform->getDoctrineTypeMapping('json')); } /** diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php index ed118aec40..9e507a3510 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\DefaultTypes; class PostgreSQL94PlatformTest extends PostgreSQL92PlatformTest { @@ -26,6 +26,6 @@ public function testInitializesJsonTypeMapping() { parent::testInitializesJsonTypeMapping(); self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); - self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); + self::assertEquals(DefaultTypes::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); } } diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php index 046118f91f..d7eeff7f1e 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; @@ -14,8 +15,8 @@ class ColumnDiffTest extends TestCase */ public function testPreservesOldColumnNameQuotation() { - $fromColumn = new Column('"foo"', Type::getType(Type::INTEGER)); - $toColumn = new Column('bar', Type::getType(Type::INTEGER)); + $fromColumn = new Column('"foo"', Type::getType(DefaultTypes::INTEGER)); + $toColumn = new Column('bar', Type::getType(DefaultTypes::INTEGER)); $columnDiff = new ColumnDiff('"foo"', $toColumn, []); self::assertTrue($columnDiff->getOldColumnName()->isQuoted()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php index 51fe749e28..5850966d7c 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; @@ -74,10 +75,10 @@ public function testSettingUnknownOptionIsStillSupported() : void */ public function testOptionsShouldNotBeIgnored() : void { - $col1 = new Column('bar', Type::getType(Type::INTEGER), ['unknown_option' => 'bar', 'notnull' => true]); + $col1 = new Column('bar', Type::getType(DefaultTypes::INTEGER), ['unknown_option' => 'bar', 'notnull' => true]); self::assertTrue($col1->getNotnull()); - $col2 = new Column('bar', Type::getType(Type::INTEGER), ['unknown_option' => 'bar', 'notnull' => false]); + $col2 = new Column('bar', Type::getType(DefaultTypes::INTEGER), ['unknown_option' => 'bar', 'notnull' => false]); self::assertFalse($col2->getNotnull()); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php index fbcf5fb935..6cc137e4c2 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\BinaryType; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DBAL\Mocks\MockPlatform; use Doctrine\Tests\DbalTestCase; @@ -35,7 +36,7 @@ public function testReturnsBindingType() public function testReturnsName() { - self::assertSame(Type::BINARY, $this->type->getName()); + self::assertSame(DefaultTypes::BINARY, $this->type->getName()); } public function testReturnsSQLDeclaration() diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 564371a30b..193087510e 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Types; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\JsonArrayType; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DBAL\Mocks\MockPlatform; @@ -35,7 +36,7 @@ public function testReturnsBindingType() public function testReturnsName() { - self::assertSame(Type::JSON_ARRAY, $this->type->getName()); + self::assertSame(DefaultTypes::JSON_ARRAY, $this->type->getName()); } public function testReturnsSQLDeclaration() diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 4f204a8bae..7fb2203a84 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\DefaultTypes; use Doctrine\DBAL\Types\JsonType; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DBAL\Mocks\MockPlatform; @@ -36,7 +37,7 @@ public function testReturnsBindingType() public function testReturnsName() { - self::assertSame(Type::JSON, $this->type->getName()); + self::assertSame(DefaultTypes::JSON, $this->type->getName()); } public function testReturnsSQLDeclaration()