Closed mszabo-wikia closed 4 years ago
Thanks for this @mszabo-wikia! Is it worth to enable warnings in CI so we can catch such things?
Is it worth to enable warnings in CI so we can catch such things?
Yes! We should be as strict as possible.
@piotrooo @mszabo-wikia see https://github.com/opentracing/opentracing-php/pull/108
Anything missing for this PR? LGTM
Short description of what this PR does:
The
MockTracer
class provided by opentracing-php allows users to provide callables implementing tracing context injection for a given format. The inject() method implementation, when called with a given context, format and carrier, looks up the user-provided callable for the given format, and invokes it via PHP'scall_user_func
function to perform the injection.This implementation is broken, because
call_user_func
passes parameters to the target by value, rather than by reference.[1] Since the injection process relies on the carrier being passed by reference, so that the injection callable can modify the carrier, this will cause a PHP Warning and cause the injection to fail, e.g.:This patch changes MockTracer::inject to invoke the injector callable directly rather than via call_user_func, and updates the corresponding unit test.
Checklist
Closes #106