Skip to content

Commit 3c997b1

Browse files
committed
next bunch of psalm fixes
1 parent 8a290be commit 3c997b1

19 files changed

+55
-24
lines changed

src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Psr\Http\Message\ResponseInterface;
1919
use Throwable;
2020

21+
/** @psalm-suppress UnusedClass */
2122
class HttpAsyncClientInstrumentation
2223
{
2324
public const NAME = 'http-async-client';
@@ -29,6 +30,7 @@ public static function register(): void
2930
schemaUrl: 'https://opentelemetry.io/schemas/1.30.0',
3031
);
3132

33+
/** @psalm-suppress UnusedFunctionCall */
3234
hook(
3335
HttpAsyncClient::class,
3436
'sendAsyncRequest',

src/Instrumentation/IO/src/IOInstrumentation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OpenTelemetry\SemConv\Version;
1515
use Throwable;
1616

17+
/** @psalm-suppress UnusedClass */
1718
class IOInstrumentation
1819
{
1920
public const NAME = 'io';
@@ -38,6 +39,7 @@ public static function register(): void
3839

3940
/**
4041
* Simple generic hook function which starts and ends a minimal span
42+
* @psalm-suppress UnusedFunctionCall
4143
*/
4244
private static function _hook(CachedInstrumentation $instrumentation, ?string $class, string $function, string $name): void
4345
{

src/Instrumentation/IO/tests/Integration/IOInstrumentationTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace OpenTelemetry\Tests\Instrumentation\IO\tests\Integration;
66

77
use ArrayObject;
8+
use CurlHandle;
89
use OpenTelemetry\API\Instrumentation\Configurator;
910
use OpenTelemetry\Context\ScopeInterface;
1011
use OpenTelemetry\SDK\Trace\ImmutableSpan;
@@ -41,6 +42,7 @@ public function tearDown(): void
4142
public function test_io_calls(): void
4243
{
4344
$resource = fopen('php://memory', 'r');
45+
$this->assertIsResource($resource);
4446
$this->assertCount(1, $this->storage);
4547
$this->span = $this->storage->offsetGet(0);
4648
$this->assertSame('fopen', $this->span->getName());
@@ -52,8 +54,8 @@ public function test_io_calls(): void
5254
$this->span = $this->storage->offsetGet(1);
5355
$this->assertSame('file_put_contents', $this->span->getName());
5456
$this->assertSame('php://memory', $this->span->getAttributes()->get('code.params.filename'));
55-
56-
$str = file_get_contents('php://memory');
57+
58+
file_get_contents('php://memory');
5759
$this->assertCount(3, $this->storage);
5860
$this->span = $this->storage->offsetGet(2);
5961
$this->assertSame('file_get_contents', $this->span->getName());
@@ -70,6 +72,7 @@ public function test_io_calls(): void
7072
$this->assertSame('fread', $this->span->getName());
7173

7274
$ch = curl_init('foo');
75+
$this->assertInstanceOf(CurlHandle::class, $ch);
7376
$this->assertCount(6, $this->storage);
7477
$this->span = $this->storage->offsetGet(5);
7578
$this->assertSame('curl_init', $this->span->getName());

src/Instrumentation/MongoDB/src/MongoDBInstrumentationSubscriber.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public function commandStarted(CommandStartedEvent $event): void
6868
$collectionName = MongoDBCollectionExtractor::extract($command);
6969
$databaseName = $event->getDatabaseName();
7070
$commandName = $event->getCommandName();
71-
/** @phpstan-ignore-next-line */
72-
if (version_compare(phpversion('mongodb'), '1.20.0', '>=')) {
71+
72+
$version = phpversion('mongodb');
73+
if ($version !== false && version_compare($version, '1.20.0', '>=')) {
7374
$host = $event->getHost();
7475
$port = $event->getPort();
7576
} else {

src/Instrumentation/Psr14/src/Psr14Instrumentation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
/**
1919
* @psalm-suppress ArgumentTypeCoercion
20+
* @psalm-suppress UnusedClass
2021
*/
2122
class Psr14Instrumentation
2223
{
@@ -32,6 +33,7 @@ public static function register(): void
3233

3334
/**
3435
* Create a span for each PSR-14 event that is dispatched.
36+
* @psalm-suppress UnusedFunctionCall
3537
*/
3638
hook(
3739
EventDispatcherInterface::class,

src/Instrumentation/Psr14/tests/Fixture/SampleEventClass.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
*/
1010
final class SampleEventClass
1111
{
12+
/** @psalm-suppress PossiblyUnusedProperty */
1213
public string $item;
1314

14-
public function __construct(
15-
string $item = 'test',
16-
) {
15+
public function __construct(string $item = 'test') {
1716
$this->item = $item;
1817
}
1918
}

src/Instrumentation/Psr15/src/Psr15Instrumentation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
/**
2323
* @psalm-suppress ArgumentTypeCoercion
24+
* @psalm-suppress UnusedClass
2425
*/
2526
class Psr15Instrumentation
2627
{

src/Instrumentation/Psr16/src/Psr16Instrumentation.php

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

5555
foreach (['get', 'set', 'delete', 'clear', 'getMultiple', 'setMultiple', 'deleteMultiple', 'has'] as $f) {
56+
/** @psalm-suppress UnusedFunctionCall */
5657
hook(class: CacheInterface::class, function: $f, pre: $pre, post: $post);
5758
}
5859
}

src/Instrumentation/Psr18/src/Psr18Instrumentation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use function strtolower;
2121
use Throwable;
2222

23+
/** @psalm-suppress UnusedClass */
2324
class Psr18Instrumentation
2425
{
2526
/** @psalm-suppress ArgumentTypeCoercion */
@@ -32,6 +33,7 @@ public static function register(): void
3233
'https://opentelemetry.io/schemas/1.30.0',
3334
);
3435

36+
/** @psalm-suppress UnusedFunctionCall */
3537
hook(
3638
ClientInterface::class,
3739
'sendRequest',

src/Instrumentation/Slim/src/PsrResponsePropagationSetter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static function instance(): self
2121
return $instance ??= new self();
2222
}
2323

24+
/** @psalm-suppress PossiblyUnusedMethod */
2425
public function keys($carrier): array
2526
{
2627
assert($carrier instanceof ResponseInterface);

0 commit comments

Comments
 (0)