@@ -51,8 +51,8 @@ public static function register(): void
5151 post: static function ($ obj , array $ params , mixed $ retVal ) use ($ curlHandleToAttributes ) {
5252 if ($ retVal instanceof CurlHandle) {
5353 $ curlHandleToAttributes [$ retVal ] = [TraceAttributes::HTTP_REQUEST_METHOD => 'GET ' ];
54- if ($ params [0 ] !== null ) {
55- $ curlHandleToAttributes [$ retVal ][TraceAttributes::URL_FULL ] = self ::redactUrlString ($ params [ 0 ] );
54+ if (( $ handle = $ params [0 ] ?? null ) !== null ) {
55+ $ curlHandleToAttributes [$ retVal ][TraceAttributes::URL_FULL ] = self ::redactUrlString ($ handle );
5656 }
5757 }
5858 }
@@ -96,7 +96,7 @@ public static function register(): void
9696 null ,
9797 'curl_close ' ,
9898 pre: static function ($ obj , array $ params ) use ($ curlHandleToAttributes ) {
99- if ($ params [0 ] instanceof CurlHandle) {
99+ if (count ( $ params ) > 0 && $ params [0 ] instanceof CurlHandle) {
100100 $ curlHandleToAttributes ->offsetUnset ($ params [0 ]);
101101 }
102102 },
@@ -118,7 +118,7 @@ public static function register(): void
118118 null ,
119119 'curl_reset ' ,
120120 pre: static function ($ obj , array $ params ) use ($ curlHandleToAttributes ) {
121- if ($ params [0 ] instanceof CurlHandle) {
121+ if (count ( $ params ) > 0 && $ params [0 ] instanceof CurlHandle) {
122122 $ curlHandleToAttributes [$ params [0 ]] = [TraceAttributes::HTTP_REQUEST_METHOD => 'GET ' ];
123123 }
124124 },
@@ -147,7 +147,7 @@ public static function register(): void
147147 $ span = $ builder ->startSpan ();
148148 Context::storage ()->attach ($ span ->storeInContext ($ parent ));
149149 },
150- post: static function ($ obj , array $ params , mixed $ retVal ) use ( $ curlHandleToAttributes ) {
150+ post: static function ($ obj , array $ params , mixed $ retVal ) {
151151 $ scope = Context::storage ()->scope ();
152152 if (!$ scope ) {
153153 return ;
@@ -359,22 +359,22 @@ private static function getAttributeFromCurlOption(int $option, mixed $value): ?
359359 private static function setAttributesFromCurlGetInfo (CurlHandle $ handle , SpanInterface $ span )
360360 {
361361 $ info = curl_getinfo ($ handle );
362- if (($ value = $ info ['http_code ' ] ?? null ) != 0 ) {
362+ if (($ value = $ info ['http_code ' ]) != 0 ) {
363363 $ span ->setAttribute (TraceAttributes::HTTP_RESPONSE_STATUS_CODE , $ value );
364364 }
365- if (($ value = $ info ['download_content_length ' ] ?? null ) > -1 ) {
365+ if (($ value = $ info ['download_content_length ' ]) > -1 ) {
366366 $ span ->setAttribute (TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH , $ value );
367367 }
368- if (($ value = $ info ['upload_content_length ' ] ?? null ) > -1 ) {
368+ if (($ value = $ info ['upload_content_length ' ]) > -1 ) {
369369 $ span ->setAttribute (TraceAttributes::HTTP_REQUEST_BODY_SIZE , $ value );
370370 }
371- if ($ value = $ info ['scheme ' ] ?? null ) {
371+ if (! empty ( $ value = $ info ['scheme ' ]) ) {
372372 $ span ->setAttribute (TraceAttributes::URL_SCHEME , $ value );
373373 }
374- if ($ value = $ info ['primary_ip ' ] ?? null ) {
374+ if (! empty ( $ value = $ info ['primary_ip ' ]) ) {
375375 $ span ->setAttribute (TraceAttributes::SERVER_ADDRESS , $ value );
376376 }
377- if ($ value = $ info ['primary_port ' ] ?? null ) {
377+ if (( $ value = $ info ['primary_port ' ]) != 0 ) {
378378 $ span ->setAttribute (TraceAttributes::SERVER_PORT , $ value );
379379 }
380380 }
0 commit comments