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

Add missing doc blocks to Index and UniqueConstraint #5875

Merged
merged 1 commit into from
Jan 28, 2023

Conversation

derrabus
Copy link
Member

Q A
Type improvement
Fixed issues N/A

Summary

Since the removal of the Constraint interface in #4842, the Index and UniqueConstraint classes were left with @inheritdoc blocks that point nowhere.

This PR restores the original doc blocks and fixes follow-up issues reported by PHPStan and Psalm.

}

$chunks[] = sprintf('(%s)', implode(', ', $columnSQL));
$chunks[] = sprintf('(%s)', implode(', ', $columns));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $columns is always a list of strings, the whole foreach loop doesn't make sense. 🧐

@@ -366,7 +366,7 @@ public function getAlterTableSQL(TableDiff $diff): array
// Necessary in case the new primary key includes a new auto_increment column
foreach ($modifiedIndexes['primary']->getColumns() as $columnName) {
if (isset($addedColumns[$columnName]) && $addedColumns[$columnName]->getAutoincrement()) {
$keyColumns = array_unique(array_values($modifiedIndexes['primary']->getColumns()));
$keyColumns = array_values(array_unique($modifiedIndexes['primary']->getColumns()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code didn't make sense. getColumns() returns a list, so it's pointless to call array_values() on it.

array_unique() however does not reindex the passed array, so if you pass a list to it with at least one duplicate, the returned array won't be a list anymore. Thus is makes sense to call array_values() in the result of the array_unique() operation if we want the array to remain a list after eliminating duplicates.

@derrabus derrabus merged commit 1cf91c1 into doctrine:4.0.x Jan 28, 2023
@derrabus derrabus deleted the bugfix/missing-docblocks branch January 28, 2023 11:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants