Skip to content

Commit

Permalink
Merge pull request #4278 from morozov/remove-dbal-exception
Browse files Browse the repository at this point in the history
Remove deprecated APIs
  • Loading branch information
morozov authored Sep 21, 2020
2 parents f8395ef + ba4c990 commit 7a5da36
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 247 deletions.
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Upgrade to 3.0

## BC BREAK: `Doctrine\DBAL\Types\Type::getDefaultLength()` removed

The `Doctrine\DBAL\Types\Type::getDefaultLength()` method has been removed as it served no purpose.

## BC BREAK: `Doctrine\DBAL\DBALException` class renamed

The `Doctrine\DBAL\DBALException` class has been renamed to `Doctrine\DBAL\Exception`.

## BC BREAK: Doctrine\DBAL\Schema\Table constructor new parameter

Deprecated parameter `$idGeneratorType` removed and added a new parameter `$uniqueConstraints`.
Expand Down
199 changes: 0 additions & 199 deletions src/DBALException.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Driver/SQLSrv/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use function stripos;

use const SQLSRV_ENC_BINARY;
use const SQLSRV_ENC_CHAR;
use const SQLSRV_PARAM_IN;

final class Statement implements StatementInterface
Expand Down
144 changes: 143 additions & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,151 @@

namespace Doctrine\DBAL;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

use function get_class;
use function gettype;
use function implode;
use function is_object;
use function spl_object_hash;
use function sprintf;

/**
* @psalm-immutable
*/
class Exception extends DBALException
class Exception extends \Exception
{
public static function notSupported(string $method): self
{
return new self(sprintf("Operation '%s' is not supported by platform.", $method));
}

/**
* @param mixed $invalidPlatform
*/
public static function invalidPlatformType($invalidPlatform): self
{
if (is_object($invalidPlatform)) {
return new self(
sprintf(
"Option 'platform' must be a subtype of '%s', instance of '%s' given",
AbstractPlatform::class,
get_class($invalidPlatform)
)
);
}

return new self(
sprintf(
"Option 'platform' must be an object and subtype of '%s'. Got '%s'",
AbstractPlatform::class,
gettype($invalidPlatform)
)
);
}

/**
* Returns a new instance for an invalid specified platform version.
*
* @param string $version The invalid platform version given.
* @param string $expectedFormat The expected platform version format.
*/
public static function invalidPlatformVersionSpecified(string $version, string $expectedFormat): self
{
return new self(
sprintf(
'Invalid platform version "%s" specified. ' .
'The platform version has to be specified in the format: "%s".',
$version,
$expectedFormat
)
);
}

/**
* @param string|null $url The URL that was provided in the connection parameters (if any).
*/
public static function driverRequired(?string $url = null): self
{
if ($url !== null) {
return new self(
sprintf(
"The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " .
'is given to DriverManager::getConnection(). Given URL: %s',
$url
)
);
}

return new self("The options 'driver' or 'driverClass' are mandatory if no PDO " .
'instance is given to DriverManager::getConnection().');
}

/**
* @param string[] $knownDrivers
*/
public static function unknownDriver(string $unknownDriverName, array $knownDrivers): self
{
return new self("The given 'driver' " . $unknownDriverName . ' is unknown, ' .
'Doctrine currently supports only the following drivers: ' . implode(', ', $knownDrivers));
}

public static function invalidWrapperClass(string $wrapperClass): self
{
return new self("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' .
'subtype of \Doctrine\DBAL\Connection.');
}

public static function invalidDriverClass(string $driverClass): self
{
return new self(
"The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.'
);
}

public static function noColumnsSpecifiedForTable(string $tableName): self
{
return new self('No columns specified for table ' . $tableName);
}

public static function limitOffsetInvalid(): self
{
return new self('Invalid Offset in Limit Query, it has to be larger than or equal to 0.');
}

public static function typeExists(string $name): self
{
return new self('Type ' . $name . ' already exists.');
}

public static function unknownColumnType(string $name): self
{
return new self('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' .
'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' .
'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' .
'introspection then you might have forgotten to register all database types for a Doctrine Type. Use ' .
'AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement ' .
'Type#getMappedDatabaseTypes(). If the type name is empty you might ' .
'have a problem with the cache or forgot some mapping information.');
}

public static function typeNotFound(string $name): self
{
return new self('Type to be overwritten ' . $name . ' does not exist.');
}

public static function typeNotRegistered(Type $type): self
{
return new self(
sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type))
);
}

public static function typeAlreadyRegistered(Type $type): self
{
return new self(
sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type))
);
}
}
12 changes: 0 additions & 12 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -3147,18 +3147,6 @@ public function supportsForeignKeyConstraints()
return true;
}

/**
* Whether this platform supports onUpdate in foreign key constraints.
*
* @deprecated
*
* @return bool
*/
public function supportsForeignKeyOnUpdate()
{
return $this->supportsForeignKeyConstraints();
}

/**
* Whether the platform supports database schemas.
*
Expand Down
Loading

0 comments on commit 7a5da36

Please sign in to comment.