From fcccc2d1d8cb5ef48be63428f2a95b5e70962089 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 2 Jul 2022 17:22:02 -0700 Subject: [PATCH] Deprecate custom schema options --- UPGRADE.md | 15 ++++++++++++++ psalm.xml.dist | 11 ++++++++++ src/Schema/Column.php | 47 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index dec877aa31f..1e6c2953c0a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,21 @@ awareness about deprecated code. # Upgrade to 3.4 +## Deprecated custom schema options. + +Custom schema options have been deprecated since they effectively duplicate the functionality of platform options. + +The following `Column` class properties and methods have been deprecated: + +- `$_customSchemaOptions`, +- `setCustomSchemaOption()`, +- `hasCustomSchemaOption()`, +- `getCustomSchemaOption()`, +- `setCustomSchemaOptions()`, +- `getCustomSchemaOptions()`. + +Use platform options instead. + ## Deprecated `array` and `object` column types. The `array` and `object` column types have been deprecated since they use PHP built-in serialization. Without additional diff --git a/psalm.xml.dist b/psalm.xml.dist index fac5d8b0b38..99b368f7a36 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -337,6 +337,13 @@ TODO: remove in 4.0.0 --> + + + + + @@ -362,6 +369,10 @@ TODO: remove in 4.0.0 --> + + diff --git a/src/Schema/Column.php b/src/Schema/Column.php index 714bbc42890..648ffb7891c 100644 --- a/src/Schema/Column.php +++ b/src/Schema/Column.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Schema\Exception\UnknownColumnOption; use Doctrine\DBAL\Types\Type; +use Doctrine\Deprecations\Deprecation; use function array_merge; use function is_numeric; @@ -50,7 +51,11 @@ class Column extends AbstractAsset /** @var string|null */ protected $_comment; - /** @var mixed[] */ + /** + * @deprecated Use {@link $_platformOptions instead} + * + * @var mixed[] + */ protected $_customSchemaOptions = []; /** @@ -374,6 +379,8 @@ public function getComment() } /** + * @deprecated Use {@link setPlatformOption() instead} + * * @param string $name * @param mixed $value * @@ -381,48 +388,86 @@ public function getComment() */ public function setCustomSchemaOption($name, $value) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5476', + 'Column::setCustomSchemaOption() is deprecated. Use setPlatformOption() instead.' + ); + $this->_customSchemaOptions[$name] = $value; return $this; } /** + * @deprecated Use {@link hasPlatformOption() instead} + * * @param string $name * * @return bool */ public function hasCustomSchemaOption($name) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5476', + 'Column::hasCustomSchemaOption() is deprecated. Use hasPlatformOption() instead.' + ); + return isset($this->_customSchemaOptions[$name]); } /** + * @deprecated Use {@link getPlatformOption() instead} + * * @param string $name * * @return mixed */ public function getCustomSchemaOption($name) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5476', + 'Column::getCustomSchemaOption() is deprecated. Use getPlatformOption() instead.' + ); + return $this->_customSchemaOptions[$name]; } /** + * @deprecated Use {@link setPlatformOptions() instead} + * * @param mixed[] $customSchemaOptions * * @return Column */ public function setCustomSchemaOptions(array $customSchemaOptions) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5476', + 'Column::setCustomSchemaOptions() is deprecated. Use setPlatformOptions() instead.' + ); + $this->_customSchemaOptions = $customSchemaOptions; return $this; } /** + * @deprecated Use {@link getPlatformOptions() instead} + * * @return mixed[] */ public function getCustomSchemaOptions() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5476', + 'Column::getCustomSchemaOptions() is deprecated. Use getPlatformOptions() instead.' + ); + return $this->_customSchemaOptions; }