original_string: public static function formatHeaders(array $headers): string
      {
          $buffer = "";
          $lines = 0;
  
          foreach ($headers as $name => $values) {
              // PHP casts integer-like keys to integers
              $name =  (string) $name;
  
              // Ignore any HTTP/2 pseudo headers
              if ($name[0] === ":") {
                  continue;
              }
  
              /** @var array $values */
              foreach ($values as $value) {
                  $buffer .= "{$name}: {$value}\r\n";
                  $lines++;
              }
          }
  
          $count = \preg_match_all(self::HEADER_REGEX, $buffer);
  
          if ($lines !== $count || $lines !== \substr_count($buffer, "\n")) {
              throw new InvalidHeaderException("Invalid headers");
          }
  
          return $buffer;
      }
code: public static function formatHeaders(array $headers): string
      {
          $buffer = "";
          $lines = 0;
  
          foreach ($headers as $name => $values) {
              // PHP casts integer-like keys to integers
              $name =  (string) $name;
  
              // Ignore any HTTP/2 pseudo headers
              if ($name[0] === ":") {
                  continue;
              }
  
              /** @var array $values */
              foreach ($values as $value) {
                  $buffer .= "{$name}: {$value}\r\n";
                  $lines++;
              }
          }
  
          $count = \preg_match_all(self::HEADER_REGEX, $buffer);
  
          if ($lines !== $count || $lines !== \substr_count($buffer, "\n")) {
              throw new InvalidHeaderException("Invalid headers");
          }
  
          return $buffer;
      }
code_tokens: public static function formatHeaders ( array $ headers ) : string { $ buffer = "" ; $ lines = 0 ; foreach ( $ headers as $ name => $ values ) { // PHP casts integer-like keys to integers $ name = ( string ) $ name ; // Ignore any HTTP/2 pseudo headers if ( $ name [ 0 ] === ":" ) { continue ; } /** @var array $values */ foreach ( $ values as $ value ) { $ buffer .= "{$name}: {$value}\r\n" ; $ lines ++ ; } } $ count = \ preg_match_all ( self :: HEADER_REGEX , $ buffer ) ; if ( $ lines !== $ count || $ lines !== \ substr_count ( $ buffer , "\n" ) ) { throw new InvalidHeaderException ( "Invalid headers" ) ; } return $ buffer ; }
docstring: Format headers in to their on-the-wire format.
  
  Headers are always validated syntactically. This protects against response splitting and header injection
  attacks.
  
  @param array $headers Headers in a format as returned by {@see parseHeaders()}.
  
  @return string Formatted headers.
  
  @throws InvalidHeaderException If header names or values are invalid.
docstring_tokens: Format headers in to their on - the - wire format .