dd-trace-php
dd-trace-php copied to clipboard
[Feature] Add phpStan stub file so
Is your feature request related to a problem? Please describe. phpstan will statically analyse source code to find potential issues. Currently as ddtrace defines functions like trace_method and classes like SpanData that phpstan doesn't know about, it will complain loudly about any custom tracing code.
Describe the solution you'd like An official stub file to give phpStan the information it needs would be fantastic.
An initial file I've been using is: ddtrace.stub
<?php
namespace DDTrace;
/**
* @param array<mixed> $args
*/
function trace_method(\DDTrace\SpanData $span, array $args, mixed $retval, ?\Exception $exception): void
{
}
namespace DDTrace;
class SpanData
{
public string $name;
public string $resource;
public string $service;
public string $type;
/** @var string[] $meta */
public $meta;
/** @var float[] $metrics */
public $metrics;
}
We have planned on moving towards PHP stub files (As a starting point I've begun experimenting with https://github.com/DataDog/dd-trace-php/blob/52106acf64fb45acd6c74f85fc58adead4a5ff4c/ext/hook/uhook.stub.php).
Expect to see this becoming reality in the coming months :-)
Looking forward to stub files, any movement here? Thanks!
We are actively planning on doing this in the next 2-3 months.
We now have the following .stub.php files (to be released soon as 0.85.0):
- ext/ddtrace.stub.php
- ext/hook/uhook.stub.php
- ext/hook/uhook_attributes.stub.php
@ralphschindler and @NickStallman I hope that's solving all the doc and autocompletion issues you were having :-)
Brilliant! Thanks. :)