Skip to content

Commit f7e2e44

Browse files
committed
More psalm issues resolved
1 parent 1130412 commit f7e2e44

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

src/Instrumentation/PDO/src/PDOTracker.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function trackedAttributesForStatement(PDOStatement $statement): iterable
5454
return [];
5555
}
5656

57-
return $this->pdoToAttributesMap[$pdo] ?? [];
57+
return $this->pdoToAttributesMap[$pdo] ?: [];
5858
}
5959

6060
/**
@@ -88,11 +88,15 @@ public function trackPdoAttributes(PDO $pdo, string $dsn): iterable
8888
*/
8989
public function trackedAttributesForPdo(PDO $pdo): iterable
9090
{
91-
return $this->pdoToAttributesMap[$pdo] ?? [];
91+
return $this->pdoToAttributesMap[$pdo] ?: [];
9292
}
9393

9494
public function getSpanForPreparedStatement(PDOStatement $statement): ?SpanContextInterface
9595
{
96+
if (!$this->preparedStatementToSpanMap->offsetExists($statement)) {
97+
return null;
98+
}
99+
96100
return ($this->preparedStatementToSpanMap[$statement] ?? null)?->get();
97101
}
98102

src/Instrumentation/Psr15/src/Psr15Instrumentation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static function register(): void
3333
/**
3434
* Create a span for each psr-15 middleware that is executed.
3535
*/
36+
/** @psalm-suppress UnusedFunctionCall */
3637
hook(
3738
MiddlewareInterface::class,
3839
'process',
@@ -65,6 +66,7 @@ public static function register(): void
6566
* Create a span to wrap RequestHandlerInterface::handle. The first execution is assumed to be the root span, which
6667
* is stored as a request attribute which may be accessed by later hooks.
6768
*/
69+
/** @psalm-suppress UnusedFunctionCall */
6870
hook(
6971
RequestHandlerInterface::class,
7072
'handle',

src/Instrumentation/Psr3/src/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function format(array $context): array
1515
if ($key === 'exception' && $value instanceof Throwable) {
1616
$formatted[$key] = self::formatThrowable($value);
1717
} else {
18-
$formatted[$key] = json_decode(json_encode($value));
18+
$formatted[$key] = json_decode(json_encode($value) ?: '');
1919
}
2020
}
2121

src/Instrumentation/Psr3/src/Psr3Instrumentation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ private static function class_uses_deep(object $class): array
116116

117117
// Get traits of all parent classes
118118
do {
119-
$traits = array_merge(class_uses($class, false), $traits);
119+
$traits = array_merge(class_uses($class, false) ?: [], $traits);
120120
} while ($class = get_parent_class($class));
121121

122122
// Get traits of all parent traits
123123
$traitsToSearch = $traits;
124124
while (!empty($traitsToSearch)) {
125-
$newTraits = class_uses(array_pop($traitsToSearch), false);
125+
$newTraits = class_uses(array_pop($traitsToSearch), false) ?: [];
126126
$traits = array_merge($newTraits, $traits);
127127
$traitsToSearch = array_merge($newTraits, $traitsToSearch);
128128
};
129129

130130
foreach ($traits as $trait => $same) {
131-
$traits = array_merge(class_uses($trait, false), $traits);
131+
$traits = array_merge(class_uses($trait, false) ?: [], $traits);
132132
}
133133

134134
return array_unique($traits);

src/Instrumentation/Psr6/src/Psr6Instrumentation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static function register(): void
5858
};
5959

6060
foreach (['getItem', 'getItems', 'hasItem', 'clear', 'deleteItem', 'deleteItems', 'save', 'saveDeferred', 'commit'] as $f) {
61+
/** @psalm-suppress UnusedFunctionCall */
6162
hook(class: CacheItemPoolInterface::class, function: $f, pre: $pre, post: $post);
6263
}
6364
}

0 commit comments

Comments
 (0)