Skip to content

Commit dcc9821

Browse files
authored
fix: resolve PDO WeakMap warning (open-telemetry#334)
Replace comparison operators with null coalescing operator to fix undefined array error. Fixes open-telemetry/opentelemetry-php#1529
1 parent 5c9ab13 commit dcc9821

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Instrumentation/PDO/src/PDOTracker.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function trackedAttributesForStatement(PDOStatement $statement): array
5757
return [];
5858
}
5959

60-
return $this->pdoToAttributesMap[$pdo] ?: [];
60+
/** @psalm-var array<non-empty-string, bool|int|float|string|array|null> */
61+
return $this->pdoToAttributesMap[$pdo] ?? [];
6162
}
6263

6364
/**
@@ -91,7 +92,8 @@ public function trackPdoAttributes(PDO $pdo, string $dsn): array
9192
*/
9293
public function trackedAttributesForPdo(PDO $pdo): array
9394
{
94-
return $this->pdoToAttributesMap[$pdo] ?: [];
95+
/** @psalm-var array<non-empty-string, bool|int|float|string|array|null> */
96+
return $this->pdoToAttributesMap[$pdo] ?? [];
9597
}
9698

9799
public function getSpanForPreparedStatement(PDOStatement $statement): ?SpanContextInterface

0 commit comments

Comments
 (0)