Skip to content

Commit

Permalink
Remove obsolete and unnecessary properties from Table attribute (do…
Browse files Browse the repository at this point in the history
…ctrine#11351)

The properties `indexes` and `uniqueConstraints` were present before and
were used for the `AnnotationDriver` but were never implemented
for the `AttributeDriver`.
Since the `AnnotationDriver` doesn't exist anymore these can be safely
removed reducing possible confusion when defining indices and
uniqueConstraints in the `Table` attribute which never worked anyway.
  • Loading branch information
DaDeather committed Mar 18, 2024
1 parent a4e71b8 commit 07fd9df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Using array access on instances of the following classes is no longer possible:
- `Doctrine\ORM\Mapping\JoinColumnMapping`
- `Doctrine\ORM\Mapping\JoinTableMapping`

## Remove properties `$indexes` and `$uniqueConstraints` from `Doctrine\ORM\Mapping\Table`

The properties `$indexes` and `$uniqueConstraints` have been removed since they had no effect at all.
The preferred way of defining indices and unique constraints is by
using the `\Doctrine\ORM\Mapping\UniqueConstraint` and `\Doctrine\ORM\Mapping\Index` attributes.

# Upgrade to 3.2

## `orm:schema-tool:update` option `--complete` is deprecated
Expand Down
28 changes: 1 addition & 27 deletions src/Mapping/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,15 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
use Doctrine\Deprecations\Deprecation;

#[Attribute(Attribute::TARGET_CLASS)]
final class Table implements MappingAttribute
{
/**
* @param array<Index>|null $indexes
* @param array<UniqueConstraint>|null $uniqueConstraints
* @param array<string,mixed> $options
*/
/** @param array<string,mixed> $options */
public function __construct(
public readonly string|null $name = null,
public readonly string|null $schema = null,
public readonly array|null $indexes = null,
public readonly array|null $uniqueConstraints = null,
public readonly array $options = [],
) {
if ($this->indexes !== null) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11357',
'Providing the property $indexes on %s does not have any effect and will be removed in Doctrine ORM 4.0. Please use the %s attribute instead.',
self::class,
Index::class,
);
}

if ($this->uniqueConstraints !== null) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11357',
'Providing the property $uniqueConstraints on %s does not have any effect and will be removed in Doctrine ORM 4.0. Please use the %s attribute instead.',
self::class,
UniqueConstraint::class,
);
}
}
}

0 comments on commit 07fd9df

Please sign in to comment.