diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 49c2ea4..2d26147 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,9 +1,14 @@ + */ + require_once 'vendor/autoload.php'; return CodingStandards\Factory::createPhpCsFixerConfig(__DIR__, [ 'rules' => [ - 'nullable_type_declaration' => ['syntax' => 'union'] - ] + 'nullable_type_declaration' => ['syntax' => 'union'], + ], ]); diff --git a/example/src/Controller/HttpClient.php b/example/src/Controller/HttpClient.php index c51b7cb..a020d65 100644 --- a/example/src/Controller/HttpClient.php +++ b/example/src/Controller/HttpClient.php @@ -65,10 +65,10 @@ private function getExtraOptions(): array return [ 'propagate' => false, 'operation_name' => 'http.get timeapi.io-time', - 'on_request' => function (array $headers, string|null $body, SpanInterface $span): void { + 'on_request' => function (array $headers, $body, SpanInterface $span): void { $span->setAttribute('request.headers', $headers); }, - 'on_response' => function (array $headers, string|null $body, SpanInterface $span): void { + 'on_response' => function (array $headers, $body, SpanInterface $span): void { $span->setAttribute('response.headers', json_encode($headers)); }, ]; diff --git a/spec/Tracing/Request/EventListener/AddUserEventSubscriberSpec.php b/spec/Tracing/Request/EventListener/AddUserEventSubscriberSpec.php index da7acdb..f78090a 100644 --- a/spec/Tracing/Request/EventListener/AddUserEventSubscriberSpec.php +++ b/spec/Tracing/Request/EventListener/AddUserEventSubscriberSpec.php @@ -7,7 +7,6 @@ namespace spec\Instrumentation\Tracing\Request\EventListener; -use Instrumentation\Tracing\Bridge\MainSpanContextInterface; use OpenTelemetry\API\Trace\SpanInterface; use OpenTelemetry\SemConv\TraceAttributes; use PhpSpec\ObjectBehavior; @@ -34,16 +33,14 @@ public function it_should_add_user_if_authenticated( SpanInterface $requestSpan, TokenStorageInterface $tokenStorage, UsernamePasswordToken $usernamePasswordToken, - MainSpanContextInterface $mainSpanContext, UserInterface $user, ): void { $user->getRoles()->willReturn(['ADMIN']); $user->getUserIdentifier()->willReturn('David'); $usernamePasswordToken->getUser()->willReturn($user); $tokenStorage->getToken()->willReturn($usernamePasswordToken); - $this->setupRequestSpan($requestSpan, $mainSpanContext); + $this->setupRequestSpan($requestSpan); $this->beConstructedWith( - $mainSpanContext, $tokenStorage ); $mainRequestEvent = $this->createRequestEvent('/somewhere/{id}', Request::METHOD_PUT); @@ -52,10 +49,9 @@ public function it_should_add_user_if_authenticated( $requestSpan->setAttribute(TraceAttributes::USER_ROLES, ['ADMIN'])->shouldHaveBeenCalled(); } - private function setupRequestSpan(SpanInterface $requestSpan, MainSpanContextInterface $mainSpanContext) + private function setupRequestSpan(SpanInterface $requestSpan) { $requestSpan->setAttribute(Argument::cetera())->willReturn($requestSpan); - $mainSpanContext->getMainSpan()->willReturn($requestSpan); } private function createRequestEvent( diff --git a/src/Semantics/ResourceInfoProvider.php b/src/Semantics/ResourceInfoProvider.php index d33231a..882edc9 100644 --- a/src/Semantics/ResourceInfoProvider.php +++ b/src/Semantics/ResourceInfoProvider.php @@ -15,7 +15,7 @@ class ResourceInfoProvider implements ResourceInfoProviderInterface { - private ?ResourceInfo $info = null; + private ResourceInfo|null $info = null; /** * @param array $attributes diff --git a/src/Tracing/HttpClient/TracedResponse.php b/src/Tracing/HttpClient/TracedResponse.php index a2194ae..30ff46d 100644 --- a/src/Tracing/HttpClient/TracedResponse.php +++ b/src/Tracing/HttpClient/TracedResponse.php @@ -22,7 +22,7 @@ class TracedResponse implements ResponseInterface, StreamableInterface { - private ?string $content = null; + private string|null $content = null; /** @var resource|null */ private $stream; @@ -88,7 +88,7 @@ public function cancel(): void } } - public function getInfo(?string $type = null): mixed + public function getInfo(string|null $type = null): mixed { return $this->response->getInfo($type); } @@ -117,7 +117,7 @@ public function toStream(bool $throw = true) * * @internal */ - public static function stream(HttpClientInterface $client, iterable $responses, ?float $timeout): \Generator + public static function stream(HttpClientInterface $client, iterable $responses, float|null $timeout): \Generator { $wrappedResponses = []; $traceableMap = new \SplObjectStorage(); diff --git a/src/Tracing/HttpClient/TracingHttpClient.php b/src/Tracing/HttpClient/TracingHttpClient.php index 0730fdd..5d1b127 100644 --- a/src/Tracing/HttpClient/TracingHttpClient.php +++ b/src/Tracing/HttpClient/TracingHttpClient.php @@ -39,9 +39,7 @@ final class TracingHttpClient implements HttpClientInterface * @param HttpClientInterface|array|null $client */ public function __construct( - HttpClientInterface|array|null $client = null, - ClientRequestOperationNameResolverInterface|null $operationNameResolver = null, - ClientRequestAttributeProviderInterface|null $attributeProvider = null, + HttpClientInterface|array|null $client = null, ClientRequestOperationNameResolverInterface|null $operationNameResolver = null, ClientRequestAttributeProviderInterface|null $attributeProvider = null, private readonly bool $propagateByDefault = true, int $maxHostConnections = 6, int $maxPendingPushes = 50, @@ -66,7 +64,7 @@ public function __construct( * operation_name: non-empty-string, * propagate: bool, * extra_attributes: array, - * on_request: callable(array>, string|null, SpanInterface): void, + * on_request: callable(array>, string|resource|null, SpanInterface): void, * on_response: callable(array>, string|resource|null, SpanInterface): void, * } * } $options diff --git a/src/Tracing/Request/EventListener/AddUserEventSubscriber.php b/src/Tracing/Request/EventListener/AddUserEventSubscriber.php index 399251f..4fd88e7 100644 --- a/src/Tracing/Request/EventListener/AddUserEventSubscriber.php +++ b/src/Tracing/Request/EventListener/AddUserEventSubscriber.php @@ -39,7 +39,7 @@ public static function getSubscribedEvents(): array ]; } - public function __construct(private readonly ?TokenStorageInterface $tokenStorage = null) + public function __construct(private readonly TokenStorageInterface|null $tokenStorage = null) { } @@ -77,7 +77,7 @@ private function getRoles(UserInterface|\Stringable|string $user): array return []; } - private function getUsername(UserInterface|\Stringable|string $user): ?string + private function getUsername(UserInterface|\Stringable|string $user): string|null { if ($user instanceof UserInterface) { if (method_exists($user, 'getUserIdentifier')) {