Skip to content

Change return type on PsrTransportFactory->create() to interface #1600

@smaddock

Description

@smaddock

Describe your environment

  • PHP 8.3.21 (cli) (built: May 6 2025 13:58:10) (NTS)
  • PHPStan - PHP Static Analysis Tool 2.1.16
  • open-telemetry/sdk 1.4.0
  • open-telemetry/exporter-otlp 1.3.0

Steps to reproduce

  • Create a new PsrTransport using PsrTransportFactory->create(), then pass that to a new OTLP exporter (any one). E.g.,
$transport = (new PsrTransportFactory())->create('http://localhost:4318/v1/traces', 'application/json');
$exporter = new SpanExporter($transport);

Then run PHPStan.

What is the expected behavior?
PHPStan passes with no errors.

What is the actual behavior?
PHPStan returns with the error:

Parameter #1 $transport of class OpenTelemetry\Contrib\Otlp\SpanExporter constructor expects OpenTelemetry\SDK\Common\Export\TransportInterface<'application/json'|'application/x-ndjson'|'application/x…'>, OpenTelemetry\SDK\Common\Export\Http\PsrTransport given. 🪪 argument.type

Additional context
I believe this just needs to be updated to TransportInterface:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions