Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract constants for built-in types from Type to Types #3356

Merged
merged 1 commit into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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\Types`.

Some of the constants were renamed in the process:
* `TARRAY`-> `ARRAY`
* `DATE` -> `DATE_MUTABLE`
* `DATETIME` -> `DATETIME_MUTABLE`
* `DATETIMETZ` -> `DATETIMETZ_MUTABLE`
* `TIME` -> `TIME_MUTABLE`

# Upgrade to 2.9

## Deprecated `Statement::fetchColumn()` with an invalid index
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/DBAL/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use function array_merge;
use function count;
use function current;
Expand Down Expand Up @@ -96,7 +97,7 @@ public function initializeDoctrineTypeMappings()
*/
public function isCommentedDoctrineType(Type $doctrineType)
{
if ($doctrineType->getName() === Type::BOOLEAN) {
if ($doctrineType->getName() === Types::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;
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

/**
* Provides the behavior, features and SQL dialect of the MariaDB 10.2 (10.2.7 GA) database platform.
Expand Down Expand Up @@ -36,6 +36,6 @@ protected function initializeDoctrineTypeMappings() : void
{
parent::initializeDoctrineTypeMappings();

$this->doctrineTypeMapping['json'] = Type::JSON;
$this->doctrineTypeMapping['json'] = Types::JSON;
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

/**
* Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform.
Expand Down Expand Up @@ -66,6 +66,6 @@ protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();

$this->doctrineTypeMapping['json'] = Type::JSON;
$this->doctrineTypeMapping['json'] = Types::JSON;
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use function sprintf;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();

$this->doctrineTypeMapping['json'] = Type::JSON;
$this->doctrineTypeMapping['json'] = Types::JSON;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

/**
* Provides the behavior, features and SQL dialect of the PostgreSQL 9.4 database platform.
Expand Down Expand Up @@ -36,6 +36,6 @@ protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();

$this->doctrineTypeMapping['jsonb'] = Type::JSON;
$this->doctrineTypeMapping['jsonb'] = Types::JSON;
}
}
3 changes: 2 additions & 1 deletion lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use const CASE_LOWER;
use function array_change_key_case;
use function array_filter;
Expand Down Expand Up @@ -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(), [Types::JSON_ARRAY, Types::JSON], true)) {
$column->setPlatformOption('jsonb', $jsonb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use RuntimeException;
use function array_merge;

Expand Down Expand Up @@ -240,12 +241,12 @@ private function getFederationTypeDefaultValue()
$federationType = Type::getType($this->shardManager->getDistributionType());

switch ($federationType->getName()) {
case Type::GUID:
case Types::GUID:
$defaultValue = '00000000-0000-0000-0000-000000000000';
break;
case Type::INTEGER:
case Type::SMALLINT:
case Type::BIGINT:
case Types::INTEGER:
case Types::SMALLINT:
case Types::BIGINT:
$defaultValue = '0';
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::TARRAY;
return Types::ARRAY;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/BigIntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BigIntType extends Type implements PhpIntegerMappingType
*/
public function getName()
{
return Type::BIGINT;
return Types::BIGINT;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Types/BinaryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
}

if (! is_resource($value)) {
throw ConversionException::conversionFailed($value, self::BINARY);
throw ConversionException::conversionFailed($value, Types::BINARY);
}

return $value;
Expand All @@ -53,7 +53,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::BINARY;
return Types::BINARY;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Types/BlobType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
}

if (! is_resource($value)) {
throw ConversionException::conversionFailed($value, self::BLOB);
throw ConversionException::conversionFailed($value, Types::BLOB);
}

return $value;
Expand All @@ -53,7 +53,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::BLOB;
return Types::BLOB;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::BOOLEAN;
return Types::BOOLEAN;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DateImmutableType extends DateType
*/
public function getName()
{
return Type::DATE_IMMUTABLE;
return Types::DATE_IMMUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateIntervalType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DateIntervalType extends Type
*/
public function getName()
{
return Type::DATEINTERVAL;
return Types::DATEINTERVAL;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateTimeImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DateTimeImmutableType extends DateTimeType
*/
public function getName()
{
return Type::DATETIME_IMMUTABLE;
return Types::DATETIME_IMMUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DateTimeType extends Type implements PhpDateTimeMappingType
*/
public function getName()
{
return Type::DATETIME;
return Types::DATETIME_MUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DateTimeTzImmutableType extends DateTimeTzType
*/
public function getName()
{
return Type::DATETIMETZ_IMMUTABLE;
return Types::DATETIMETZ_IMMUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateTimeTzType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DateTimeTzType extends Type implements PhpDateTimeMappingType
*/
public function getName()
{
return Type::DATETIMETZ;
return Types::DATETIMETZ_MUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DateType extends Type
*/
public function getName()
{
return Type::DATE;
return Types::DATE_MUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/DecimalType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DecimalType extends Type
*/
public function getName()
{
return Type::DECIMAL;
return Types::DECIMAL;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/FloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FloatType extends Type
*/
public function getName()
{
return Type::FLOAT;
return Types::FLOAT;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/GuidType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
*/
public function getName()
{
return Type::GUID;
return Types::GUID;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/IntegerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IntegerType extends Type implements PhpIntegerMappingType
*/
public function getName()
{
return Type::INTEGER;
return Types::INTEGER;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/JsonArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::JSON_ARRAY;
return Types::JSON_ARRAY;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/JsonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::JSON;
return Types::JSON;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::OBJECT;
return Types::OBJECT;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/SimpleArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::SIMPLE_ARRAY;
return Types::SIMPLE_ARRAY;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/SmallIntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SmallIntType extends Type implements PhpIntegerMappingType
*/
public function getName()
{
return Type::SMALLINT;
return Types::SMALLINT;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function getDefaultLength(AbstractPlatform $platform)
*/
public function getName()
{
return Type::STRING;
return Types::STRING;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/TextType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
*/
public function getName()
{
return Type::TEXT;
return Types::TEXT;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/TimeImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TimeImmutableType extends TimeType
*/
public function getName()
{
return Type::TIME_IMMUTABLE;
return Types::TIME_IMMUTABLE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Types/TimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TimeType extends Type
*/
public function getName()
{
return Type::TIME;
return Types::TIME_MUTABLE;
}

/**
Expand Down
Loading