original_string: protected function parseHeaders($stream, $uid)
      {
          $rawHeaders = imap_fetchheader($stream, $uid, static::$fetchFlags);
  
          $headers = [];
          $key = null;
  
          foreach (explode("\n", $rawHeaders) as $line) {
              // Test if continutation
              if ($line !== '' && !preg_match('/^\s/', $line)) {
                  list($key, $val) = explode(':', $line, 2);
                  $headers[$key] = trim($val);
              } elseif (!is_null($key) && ($trimmed = trim($line)) !== '') {
                  $headers[$key] = $headers[$key].$trimmed;
              }
          }
  
          foreach($headers as $headerKey => $headerValue) {
              if (preg_match('/(\w+)=(\S+);(?:\s|$)/', $headerValue)) {
                  $headers[$headerKey] = $this->parseNestedKeyPairHeader($headerValue);
              }
          }
  
          return $headers;
      }
code: protected function parseHeaders($stream, $uid)
      {
          $rawHeaders = imap_fetchheader($stream, $uid, static::$fetchFlags);
  
          $headers = [];
          $key = null;
  
          foreach (explode("\n", $rawHeaders) as $line) {
              // Test if continutation
              if ($line !== '' && !preg_match('/^\s/', $line)) {
                  list($key, $val) = explode(':', $line, 2);
                  $headers[$key] = trim($val);
              } elseif (!is_null($key) && ($trimmed = trim($line)) !== '') {
                  $headers[$key] = $headers[$key].$trimmed;
              }
          }
  
          foreach($headers as $headerKey => $headerValue) {
              if (preg_match('/(\w+)=(\S+);(?:\s|$)/', $headerValue)) {
                  $headers[$headerKey] = $this->parseNestedKeyPairHeader($headerValue);
              }
          }
  
          return $headers;
      }
code_tokens: protected function parseHeaders ( $ stream , $ uid ) { $ rawHeaders = imap_fetchheader ( $ stream , $ uid , static :: $ fetchFlags ) ; $ headers = [ ] ; $ key = null ; foreach ( explode ( "\n" , $ rawHeaders ) as $ line ) { // Test if continutation if ( $ line !== '' && ! preg_match ( '/^\s/' , $ line ) ) { list ( $ key , $ val ) = explode ( ':' , $ line , 2 ) ; $ headers [ $ key ] = trim ( $ val ) ; } elseif ( ! is_null ( $ key ) && ( $ trimmed = trim ( $ line ) ) !== '' ) { $ headers [ $ key ] = $ headers [ $ key ] . $ trimmed ; } } foreach ( $ headers as $ headerKey => $ headerValue ) { if ( preg_match ( '/(\w+)=(\S+);(?:\s|$)/' , $ headerValue ) ) { $ headers [ $ headerKey ] = $ this -> parseNestedKeyPairHeader ( $ headerValue ) ; } } return $ headers ; }
docstring: Parse the email headers into array structure
  
  @param  resource $stream
  @param  int $uid
  @return array
docstring_tokens: Parse the email headers into array structure