Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fatal errors in ddtrace.stub.php #2953

Closed
sleepyboy opened this issue Nov 14, 2024 · 2 comments
Closed

[Bug]: Fatal errors in ddtrace.stub.php #2953

sleepyboy opened this issue Nov 14, 2024 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@sleepyboy
Copy link

Bug report

ddtrace.stub.php causes fatal errors in PHP 8:

Fatal error: Type mixed cannot be marked as nullable since mixed already includes null in $PATH/vendor/datadog/dd-trace/ext/ddtrace.stub.php on line 801

PHP Fatal error:  Type mixed cannot be marked as nullable since mixed already includes null in $PATH/vendor/datadog/dd-trace/ext/ddtrace.stub.php on line 811

This can be fixed by changing signature from ?mixed $body = null to mixed $body = null.

Once these errors are fixed, there will be multiple undefined constant errors:


Fatal error: Uncaught Error: Undefined constant "DDTrace\Internal\UNKNOWN" in $PATH/vendor/datadog/dd-trace/ext/ddtrace.stub.php on line 841

Fatal error: Uncaught Error: Undefined constant "UNKNOWN" in $PATH/vendor/datadog/dd-trace/ext/ddtrace.stub.php on line 874

These can be fixed by adding something like that to corresponding namespaces:

const UNKNOWN = 0;

For instance, this would fix the first undefined constant error:

<?php
namespace DDTrace {
    const UNKNOWN = 0; // this should fix it

    /**
     * @var int
     * @cvalue DD_TRACE_DBM_PROPAGATION_DISABLED
     */
    const DBM_PROPAGATION_DISABLED = UNKNOWN;
   ....
}

How to reproduce:
Create a test PHP file (eg. test.php) and include the stub file:

<?php

include('vendor/datadog/dd-trace/ext/ddtrace.stub.php');

Execute the file from a command line using PHP 8:

php test.php

PHP version

8.3

Tracer or profiler version

1.4.2

Installed extensions

No response

Output of phpinfo()

No response

Upgrading from

No response

@sleepyboy sleepyboy added the 🐛 bug Something isn't working label Nov 14, 2024
@bwoebi
Copy link
Collaborator

bwoebi commented Nov 14, 2024

Hey @sleepyboy,

we just noticed that today and already fixed it in #2933, where we removed these extra question marks.

Thanks for reporting though!

@bwoebi bwoebi closed this as completed Nov 14, 2024
@bwoebi bwoebi reopened this Nov 14, 2024
@bwoebi
Copy link
Collaborator

bwoebi commented Nov 14, 2024

These UNKNOWN constants are special placeholders of the arginfo generator (https://github.com/php/php-src/blob/master/build/gen_stub.php). We cannot change these or put UNKNOWN there, as that would have the stub generator create an actual UNKNOWN constant for dd-trace-php. If you look at stubs from php-src itself, you'll also find this UNKNOWN constant there.

I suppose, if you want to actually include the stubs directly, you'll have to define a dummy const UNKNOWN = 0; or similar, right before including.

@bwoebi bwoebi closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants