spiral / framework

High-Performance PHP Framework
https://spiral.dev
MIT License
1.82k stars 89 forks source link

[psalm fix level 4] TracerFactoryInterface - not internal #1119

Closed gam6itko closed 3 months ago

gam6itko commented 3 months ago
Q A
Bugfix?
Breaks BC?
New feature?
Issues #...
Docs PR spiral/docs#...

Remove internal annotation from:

Psalm level 4 triggers error


use Spiral\Telemetry\TracerFactoryInterface;

final class TelemetryDecorator implements ResponseDataHandlerInterface
{
    public function __construct(
        private readonly TracerFactoryInterface       $tracerFactory,
        private readonly ResponseDataHandlerInterface $inner,
    ) {
    }

    public function handle(array $responseData, array $options = []): array
    {     
        return $this->tracerFactory
            ->make()
            ->trace(
                name: sprintf('ResponseDataHandler [%s]', get_class($this->inner)),
                callback: fn () => $this->inner->handle($responseData, $options),
                attributes: [
                    'itemsCount' => count($responseData),
                    'options' => $options,
                ]
            );
    }
}
ERROR: InternalMethod
at /home/gam6itko/TelemetryDecorator.php:23:15
The method Spiral\Telemetry\TracerFactoryInterface::make is internal to Spiral but called from TelemetryDecorator::handle (see https://psalm.dev/175)
            ->make()

ERROR: InternalMethod
at /home/gam6itko/TelemetryDecorator.php:24:15
The method Spiral\Telemetry\TracerInterface::trace is internal to Spiral but called from TelemetryDecorator::handle (see https://psalm.dev/175)
            ->trace(

The usage example. https://spiral.dev/docs/advanced-telemetry/current/en#create-trace-from-context

roxblnfk commented 3 months ago

If we make these classes non-internal, then the message "The component is under development" needs to be removed.

@butschster is it still under development?

butschster commented 3 months ago

If we make these classes non-internal, then the message "The component is under development" needs to be removed.

@butschster is it still under development?

Nope, it's all done now. Also, let's delete the other part of the line "The component is under development" as well.

Cheers!

gam6itko commented 3 months ago

deleted