Skip to content

Conversation

@morozov
Copy link
Member

@morozov morozov commented Feb 18, 2025

This PR fixes false-positive primary key column length deprecation introduced in #6787. Originally, it would trigger if the array of column lengths passed to a primary key index is not empty. This is too strict since during introspection lengths are populated with null values by default:

$result[$keyName]['options']['lengths'][] = $row['length'] ?? null;

Instead, we want to trigger the deprecation only if a non-null length would be associated with an indexed column.

Additionally, I want to introduce two more deprecation-related changes:

  1. Deprecate extending the Index class similar to UniqueConstraint and ForeignKeyConstraint.
  2. Annotate all methods accepting a list of index columns as accepting a non-empty list.

I had to add a couple of @phpstan-ignores because even though Index and UniqueConstraint accept a non-empty list of column names, they initialize their corresponding properties with an empty array and then populate them by calling a protected method. So this property has to be initialized with an empty array and thus cannot be guaranteed to be non-empty.

@morozov morozov requested a review from greg0ire February 18, 2025 06:12
@morozov morozov added this to the 4.3.0 milestone Feb 18, 2025
@morozov morozov marked this pull request as ready for review February 18, 2025 06:14
@morozov morozov merged commit ad8dabe into doctrine:4.3.x Feb 18, 2025
67 checks passed
@morozov morozov deleted the index-deprecations branch February 18, 2025 23:36
This was referenced Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants