@@ -338,8 +338,10 @@ public static function register(): void
338338 //TODO test to https://www.php.net/manual/en/mysqli.begin-transaction.php
339339 }
340340
341+ /** @param non-empty-string $spanName */
341342 private static function constructPreHook (string $ spanName , int $ paramsOffset , CachedInstrumentation $ instrumentation , MySqliTracker $ tracker , $ obj , array $ params , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno ): void
342343 {
344+ $ attributes = [];
343345 $ attributes [TraceAttributes::SERVER_ADDRESS ] = $ params [$ paramsOffset + 0 ] ?? get_cfg_var ('mysqli.default_host ' );
344346 $ attributes [TraceAttributes::SERVER_PORT ] = $ params [$ paramsOffset + 4 ] ?? get_cfg_var ('mysqli.default_port ' );
345347 $ attributes [TraceAttributes::DB_USER ] = $ params [$ paramsOffset + 1 ] ?? get_cfg_var ('mysqli.default_user ' );
@@ -370,6 +372,7 @@ private static function constructPostHook(int $paramsOffset, CachedInstrumentati
370372
371373 }
372374
375+ /** @param non-empty-string $spanName */
373376 private static function queryPreHook (string $ spanName , CachedInstrumentation $ instrumentation , MySqliTracker $ tracker , $ obj , array $ params , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno ): void
374377 {
375378 self ::startSpan ($ spanName , $ instrumentation , $ class , $ function , $ filename , $ lineno , []);
@@ -421,6 +424,7 @@ private static function multiQueryPostHook(CachedInstrumentation $instrumentatio
421424
422425 }
423426
427+ /** @param non-empty-string $spanName */
424428 private static function nextResultPreHook (string $ spanName , CachedInstrumentation $ instrumentation , MySqliTracker $ tracker , $ obj , array $ params , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno ): void
425429 {
426430 $ span = self ::startSpan ($ spanName , $ instrumentation , $ class , $ function , $ filename , $ lineno , []);
@@ -545,6 +549,7 @@ private static function stmtConstructPostHook(CachedInstrumentation $instrumenta
545549 }
546550 }
547551
552+ /** @param non-empty-string $spanName */
548553 private static function stmtExecutePreHook (string $ spanName , CachedInstrumentation $ instrumentation , MySqliTracker $ tracker , $ obj , array $ params , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno ): void
549554 {
550555 self ::startSpan ($ spanName , $ instrumentation , $ class , $ function , $ filename , $ lineno , []);
@@ -568,6 +573,7 @@ private static function stmtExecutePostHook(CachedInstrumentation $instrumentati
568573
569574 }
570575
576+ /** @param non-empty-string $spanName */
571577 private static function stmtNextResultPreHook (string $ spanName , CachedInstrumentation $ instrumentation , MySqliTracker $ tracker , $ obj , array $ params , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno ): void
572578 {
573579 $ span = self ::startSpan ($ spanName , $ instrumentation , $ class , $ function , $ filename , $ lineno , []);
@@ -603,6 +609,7 @@ private static function stmtNextResultPostHook(CachedInstrumentation $instrument
603609 self ::endSpan ($ attributes , $ exception , $ errorStatus );
604610 }
605611
612+ /** @param non-empty-string $spanName */
606613 private static function startSpan (string $ spanName , CachedInstrumentation $ instrumentation , ?string $ class , ?string $ function , ?string $ filename , ?int $ lineno , iterable $ attributes ) : SpanInterface
607614 {
608615 $ parent = Context::getCurrent ();
@@ -624,7 +631,7 @@ private static function startSpan(string $spanName, CachedInstrumentation $instr
624631 return $ span ;
625632 }
626633
627- private static function endSpan (array $ attributes , ?\Throwable $ exception , ?string $ errorStatus )
634+ private static function endSpan (iterable $ attributes , ?\Throwable $ exception , ?string $ errorStatus )
628635 {
629636 $ scope = Context::storage ()->scope ();
630637 if (!$ scope ) {
@@ -661,6 +668,7 @@ private static function dropSpan()
661668 private static function extractQueryCommand ($ query ) : ?string
662669 {
663670 $ query = preg_replace ("/ \r\n| \n\r| \r/ " , "\n" , $ query );
671+ /** @psalm-suppress PossiblyInvalidArgument */
664672 if (preg_match ('/^\s*(?:--[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*([a-zA-Z_][a-zA-Z0-9_]*)/i ' , $ query , $ matches )) {
665673 return strtoupper ($ matches [1 ]);
666674 }
0 commit comments