Skip to content

Commit 9173ef8

Browse files
committed
linting/static analysis fixes
1 parent 298bf69 commit 9173ef8

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/Instrumentation/ReactHTTP/examples/http+async_nonblocking.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
Loop::futureTick(async(static function () use ($context, $root) {
4343
$contextScope = $context->activate();
4444
$rootScope = $root->activate();
45+
4546
try {
4647
$browser = new Browser();
4748

src/Instrumentation/ReactHTTP/examples/http_only.php

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

3838
Loop::futureTick(static function () use ($root) {
3939
$rootScope = $root->activate();
40+
4041
try {
4142
$browser = new Browser();
4243

src/Instrumentation/ReactHTTP/examples/http_only_promises.php

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

3838
Loop::futureTick(static function () use ($root) {
3939
$rootScope = $root->activate();
40+
4041
try {
4142
$browser = new Browser();
4243

src/Instrumentation/ReactHTTP/src/ReactHttpInstrumentation.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function register(): void
3434
hook(
3535
Transaction::class,
3636
'send',
37-
pre: static function (Transaction $transaction, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): ?array {
37+
pre: static function (Transaction $transaction, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): array {
3838
$request = $params[0];
3939

4040
$propagator = Globals::propagator();
@@ -44,11 +44,10 @@ public static function register(): void
4444
$request = $request->withoutHeader($field);
4545
}
4646

47-
/** @psalm-suppress ArgumentTypeCoercion */
4847
$spanBuilder = $instrumentation
4948
->tracer()
5049
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-client-span
51-
->spanBuilder(sprintf('%s', $request->getMethod()))
50+
->spanBuilder(sprintf('%s', $request->getMethod()) ?: 'HTTP')
5251
->setParent($parentContext)
5352
->setSpanKind(SpanKind::KIND_CLIENT)
5453
->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod())
@@ -88,6 +87,7 @@ public static function register(): void
8887

8988
return [$request];
9089
},
90+
/** @psalm-suppress UnusedClosureParam */
9191
post: static function (Transaction $transaction, array $params, PromiseInterface $promise, ?Throwable $exception): PromiseInterface {
9292
$scope = Context::storage()->scope();
9393
$scope?->detach();
@@ -111,7 +111,6 @@ public static function register(): void
111111
// @codeCoverageIgnoreStart
112112
foreach ((array) (get_cfg_var('otel.instrumentation.http.response_headers') ?: []) as $header) {
113113
if ($response->hasHeader($header)) {
114-
/** @psalm-suppress ArgumentTypeCoercion */
115114
$span->setAttribute(
116115
sprintf('%s.%s', TraceAttributes::HTTP_RESPONSE_HEADER, strtolower($header)),
117116
$response->getHeaderLine($header)
@@ -136,7 +135,6 @@ public static function register(): void
136135
// @codeCoverageIgnoreStart
137136
foreach ((array) (get_cfg_var('otel.instrumentation.http.response_headers') ?: []) as $header) {
138137
if ($t->getResponse()->hasHeader($header)) {
139-
/** @psalm-suppress ArgumentTypeCoercion */
140138
$span->setAttribute(
141139
sprintf('%s.%s', TraceAttributes::HTTP_RESPONSE_HEADER, strtolower($header)),
142140
$t->getResponse()->getHeaderLine($header)

src/Instrumentation/ReactHTTP/tests/Integration/ReactHttpInstrumentationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public function setUp(): void
5252
$sender->method('send')
5353
->willReturnCallback(function (RequestInterface $request) {
5454
return match ($request->getUri()->getPath()) {
55-
'/success' => resolve(Response::plaintext('Hello world')),
5655
'/network_error' => resolve((new Response())->withStatus(400)),
57-
'/unknown_error' => reject(new \Exception('Unknown'))
56+
'/unknown_error' => reject(new \Exception('Unknown')),
57+
default => resolve(Response::plaintext('Hello world'))
5858
};
5959
});
60+
/** @psalm-suppress InternalClass,InternalMethod */
6061
$transaction = new Transaction($sender, $loop);
6162
$this->browser = new Browser(null, $loop);
6263
$ref = new \ReflectionProperty($this->browser, 'transaction');
63-
$ref->setAccessible(true);
6464
$ref->setValue($this->browser, $transaction);
6565

6666
/**

0 commit comments

Comments
 (0)