Skip to content

Commit bee77a6

Browse files
committed
Refine dbal 3/4 primary key shim: capability check and scoped phpstan ignores
1 parent 1d5c116 commit bee77a6

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ parameters:
33
paths:
44
- src
55
customRulesetUsed: true
6+
# dbal 3/4 shim ignores only match one major at a time.
67
reportUnmatchedIgnoredErrors: false
78
ignoreErrors: { }

src/Storage/DbalNestedSetSchema.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,23 @@ public function create(): void {
2424
$tree->addColumn("right_pos", "integer", ["unsigned" => TRUE]);
2525
$tree->addColumn("depth", "integer", ["unsigned" => TRUE]);
2626

27-
if (\class_exists('\Doctrine\DBAL\Schema\Name\UnqualifiedName')) {
27+
// @phpstan-ignore function.alreadyNarrowedType
28+
if (\method_exists($tree, 'addPrimaryKeyConstraint')) {
2829
// doctrine/dbal 4.
29-
// @phpstan-ignore-next-line
30-
$tree->addPrimaryKeyConstraint(new PrimaryKeyConstraint(
31-
UnqualifiedName::unquoted('primary'), [
32-
UnqualifiedName::unquoted('id'),
33-
UnqualifiedName::unquoted('revision_id'),
34-
],
35-
FALSE,
36-
));
30+
// @phpstan-ignore class.notFound
31+
$primary = UnqualifiedName::unquoted('primary');
32+
$columns = [
33+
// @phpstan-ignore class.notFound
34+
UnqualifiedName::unquoted('id'),
35+
// @phpstan-ignore class.notFound
36+
UnqualifiedName::unquoted('revision_id'),
37+
];
38+
// @phpstan-ignore method.notFound, class.notFound
39+
$tree->addPrimaryKeyConstraint(new PrimaryKeyConstraint($primary, $columns, FALSE));
3740
}
3841
else {
3942
// doctrine/dbal 3.
40-
// @phpstan-ignore-next-line
43+
// @phpstan-ignore method.deprecated
4144
$tree->setPrimaryKey(['id', 'revision_id']);
4245
}
4346
$tree->addIndex(['revision_id']);

0 commit comments

Comments
 (0)