Unverified Commit 138eb852 authored by Jonathan H. Wage's avatar Jonathan H. Wage Committed by Sergei Morozov

Remove deprecated stuff for 3.0

parent c58dd2fb
......@@ -4,9 +4,6 @@ namespace Doctrine\DBAL;
use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\Schema\AbstractAsset;
use function preg_match;
/**
* Configuration container for the Doctrine DBAL.
......@@ -64,43 +61,6 @@ class Configuration
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}
/**
* Sets the filter schema assets expression.
*
* Only include tables/sequences matching the filter expression regexp in
* schema instances generated for the active connection when calling
* {AbstractSchemaManager#createSchema()}.
*
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
*
* @param string|null $filterExpression
*
* @return void
*/
public function setFilterSchemaAssetsExpression($filterExpression)
{
$this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
if ($filterExpression !== null) {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = $this->buildSchemaAssetsFilterFromExpression($filterExpression);
} else {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = null;
}
}
/**
* @param string $filterExpression
*/
private function buildSchemaAssetsFilterFromExpression($filterExpression): callable
{
return static function ($assetName) use ($filterExpression) {
if ($assetName instanceof AbstractAsset) {
$assetName = $assetName->getName();
}
return preg_match($filterExpression, $assetName);
};
}
/**
* Sets the callable to use to filter schema assets.
*/
......
......@@ -70,10 +70,8 @@ final class SQLSrvStatement implements Statement
/**
* Append to any INSERT query to retrieve the last insert id.
*
* @deprecated This constant has been deprecated and will be made private in 3.0
*/
public const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;';
private const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;';
/**
* @param resource $conn
......
......@@ -2322,7 +2322,7 @@ abstract class AbstractPlatform
}
return 'CONSTRAINT ' . $name->getQuotedName($this) . ' UNIQUE ('
. $this->getIndexFieldDeclarationListSQL($index)
. $this->getColumnsFieldDeclarationListSQL($columns)
. ')' . $this->getPartialIndexSQL($index);
}
......@@ -2368,22 +2368,23 @@ abstract class AbstractPlatform
/**
* Obtains DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
*
* @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method
*/
public function getIndexFieldDeclarationListSQL($columnsOrIndex): string
public function getIndexFieldDeclarationListSQL(Index $index): string
{
if ($columnsOrIndex instanceof Index) {
return implode(', ', $columnsOrIndex->getQuotedColumns($this));
}
if (! is_array($columnsOrIndex)) {
throw new InvalidArgumentException('Fields argument should be an Index or array.');
}
return implode(', ', $index->getQuotedColumns($this));
}
/**
* Obtains DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
*
* @param mixed[] $columns
*/
public function getColumnsFieldDeclarationListSQL(array $columns): string
{
$ret = [];
foreach ($columnsOrIndex as $column => $definition) {
foreach ($columns as $column => $definition) {
if (is_array($definition)) {
$ret[] = $column;
} else {
......
......@@ -1158,8 +1158,8 @@ SQL
'int8' => 'bigint',
'integer' => 'integer',
'interval' => 'string',
'json' => Type::JSON,
'jsonb' => Type::JSON,
'json' => 'json',
'jsonb' => 'json',
'money' => 'decimal',
'numeric' => 'decimal',
'serial' => 'integer',
......
......@@ -32,16 +32,13 @@ class SQLParserUtils
/**#@+
* Quote characters within string literals can be preceded by a backslash.
*
* @deprecated Will be removed as internal implementation details.
*/
public const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')";
public const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")';
public const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)';
private const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')";
private const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")';
private const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)';
private const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]';
/**#@-*/
private const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]';
/**
* Returns a zero-indexed list of placeholder position.
*
......
......@@ -2,15 +2,12 @@
namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Exception\UnknownColumnOption;
use Doctrine\DBAL\Types\Type;
use function array_merge;
use function is_numeric;
use function method_exists;
use function sprintf;
use function trigger_error;
use const E_USER_DEPRECATED;
/**
* Object representation of a database column.
......@@ -78,15 +75,9 @@ class Column extends AbstractAsset
{
foreach ($options as $name => $value) {
$method = 'set' . $name;
if (! method_exists($this, $method)) {
// next major: throw an exception
@trigger_error(sprintf(
'The "%s" column option is not supported,' .
' setting it is deprecated and will cause an error in Doctrine DBAL 3.0',
$name
), E_USER_DEPRECATED);
continue;
throw UnknownColumnOption::new($name);
}
$this->$method($value);
......
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Schema\Exception;
use Doctrine\DBAL\Schema\SchemaException;
use function sprintf;
/**
* @psalm-immutable
*/
final class UnknownColumnOption extends SchemaException
{
public static function new(string $name): self
{
return new self(
sprintf('The "%s" column option is not supported.', $name)
);
}
}
......@@ -19,78 +19,6 @@ use function substr;
*/
abstract class Type
{
/** @deprecated Use {@see Types::BIGINT} instead. */
public const BIGINT = Types::BIGINT;
/** @deprecated Use {@see Types::BINARY} instead. */
public const BINARY = Types::BINARY;
/** @deprecated Use {@see Types::BLOB} instead. */
public const BLOB = Types::BLOB;
/** @deprecated Use {@see Types::BOOLEAN} instead. */
public const BOOLEAN = Types::BOOLEAN;
/** @deprecated Use {@see Types::DATE_MUTABLE} instead. */
public const DATE = Types::DATE_MUTABLE;
/** @deprecated Use {@see Types::DATE_IMMUTABLE} instead. */
public const DATE_IMMUTABLE = Types::DATE_IMMUTABLE;
/** @deprecated Use {@see Types::DATEINTERVAL} instead. */
public const DATEINTERVAL = Types::DATEINTERVAL;
/** @deprecated Use {@see Types::DATETIME_MUTABLE} instead. */
public const DATETIME = Types::DATETIME_MUTABLE;
/** @deprecated Use {@see Types::DATETIME_IMMUTABLE} instead. */
public const DATETIME_IMMUTABLE = Types::DATETIME_IMMUTABLE;
/** @deprecated Use {@see Types::DATETIMETZ_MUTABLE} instead. */
public const DATETIMETZ = Types::DATETIMETZ_MUTABLE;
/** @deprecated Use {@see Types::DATETIMETZ_IMMUTABLE} instead. */
public const DATETIMETZ_IMMUTABLE = Types::DATETIMETZ_IMMUTABLE;
/** @deprecated Use {@see Types::DECIMAL} instead. */
public const DECIMAL = Types::DECIMAL;
/** @deprecated Use {@see Types::FLOAT} instead. */
public const FLOAT = Types::FLOAT;
/** @deprecated Use {@see Types::GUID} instead. */
public const GUID = Types::GUID;
/** @deprecated Use {@see Types::INTEGER} instead. */
public const INTEGER = Types::INTEGER;
/** @deprecated Use {@see Types::JSON} instead. */
public const JSON = Types::JSON;
/** @deprecated Use {@see Types::OBJECT} instead. */
public const OBJECT = Types::OBJECT;
/** @deprecated Use {@see Types::SIMPLE_ARRAY} instead. */
public const SIMPLE_ARRAY = Types::SIMPLE_ARRAY;
/** @deprecated Use {@see Types::SMALLINT} instead. */
public const SMALLINT = Types::SMALLINT;
/** @deprecated Use {@see Types::STRING} instead. */
public const STRING = Types::STRING;
/** @deprecated Use {@see Types::ARRAY} instead. */
public const TARRAY = Types::ARRAY;
/** @deprecated Use {@see Types::TEXT} instead. */
public const TEXT = Types::TEXT;
/** @deprecated Use {@see Types::TIME_MUTABLE} instead. */
public const TIME = Types::TIME_MUTABLE;
/** @deprecated Use {@see Types::TIME_IMMUTABLE} instead. */
public const TIME_IMMUTABLE = Types::TIME_IMMUTABLE;
/**
* The map of supported doctrine mapping types.
*/
......
......@@ -34,9 +34,6 @@ final class Types
public const TIME_MUTABLE = 'time';
public const TIME_IMMUTABLE = 'time_immutable';
/** @deprecated json_array type is deprecated, use {@see self::JSON} instead. */
public const JSON_ARRAY = 'json_array';
private function __construct()
{
}
......
......@@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Tests\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase
{
......@@ -84,9 +84,9 @@ class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase
public function testInitializesJsonTypeMapping(): void
{
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json'));
self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('json'));
self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('json'));
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb'));
self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb'));
self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('jsonb'));
}
/**
......
......@@ -6,6 +6,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Exception\UnknownColumnOption;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use PHPUnit\Framework\TestCase;
......@@ -66,7 +67,8 @@ class ColumnTest extends TestCase
*/
public function testSettingUnknownOptionIsStillSupported(): void
{
$this->expectNotToPerformAssertions();
self::expectException(UnknownColumnOption::class);
self::expectExceptionMessage('The "unknown_option" column option is not supported.');
new Column('foo', $this->createMock(Type::class), ['unknown_option' => 'bar']);
}
......@@ -77,6 +79,9 @@ class ColumnTest extends TestCase
*/
public function testOptionsShouldNotBeIgnored(): void
{
self::expectException(UnknownColumnOption::class);
self::expectExceptionMessage('The "unknown_option" column option is not supported.');
$col1 = new Column('bar', Type::getType(Types::INTEGER), ['unknown_option' => 'bar', 'notnull' => true]);
self::assertTrue($col1->getNotnull());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment