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

Deprecate custom schema options #5476

Merged
merged 1 commit into from
Jul 3, 2022
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
15 changes: 15 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Driver::getSchemaManager"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Schema\Column::getCustomSchemaOption"/>
<referencedMethod name="Doctrine\DBAL\Schema\Column::getCustomSchemaOptions"/>
<referencedMethod name="Doctrine\DBAL\Schema\Column::hasCustomSchemaOption"/>
<referencedMethod name="Doctrine\DBAL\Schema\Column::setCustomSchemaOption"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand All @@ -362,6 +369,10 @@
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Platforms\AbstractPlatform::$doctrineTypeComments"/>
<!--
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Schema\Column::$_customSchemaOptions"/>
</errorLevel>
</DeprecatedProperty>
<DocblockTypeContradiction>
Expand Down
47 changes: 46 additions & 1 deletion src/Schema/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +51,11 @@ class Column extends AbstractAsset
/** @var string|null */
protected $_comment;

/** @var mixed[] */
/**
* @deprecated Use {@link $_platformOptions instead}
*
* @var mixed[]
*/
protected $_customSchemaOptions = [];

/**
Expand Down Expand Up @@ -374,55 +379,95 @@ public function getComment()
}

/**
* @deprecated Use {@link setPlatformOption() instead}
*
* @param string $name
* @param mixed $value
*
* @return Column
*/
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;
}

Expand Down