original_string: public function fetch($items, $from, $to = null)
      {
          if (is_array($from)) {
              $set = implode(',', $from);
          } else if ($to === null) {
              $set = (int)$from;
          } else if ($to === INF) {
              $set = (int)$from . ':*';
          } else {
              $set = (int)$from . ':' . (int)$to;
          }
  
          $items = (array)$items;
          $itemList = $this->escapeList($items);
  
          $this->sendRequest('FETCH', array($set, $itemList), $tag);
  
          $result = array();
          while (!$this->readLine($tokens, $tag)) {
              // ignore other responses
              if ($tokens[1] != 'FETCH') {
                  continue;
              }
              // ignore other messages
              if ($to === null && !is_array($from) && $tokens[0] != $from) {
                  continue;
              }
              // if we only want one item we return that one directly
              if (count($items) == 1) {
                  if ($tokens[2][0] == $items[0]) {
                      $data = $tokens[2][1];
                  } else {
                      // maybe the server send an other field we didn't wanted
                      $count = count($tokens[2]);
                      // we start with 2, because 0 was already checked
                      for ($i = 2; $i < $count; $i += 2) {
                          if ($tokens[2][$i] != $items[0]) {
                              continue;
                          }
                          $data = $tokens[2][$i + 1];
                          break;
                      }
                  }
              } else {
                  $data = array();
                  while (key($tokens[2]) !== null) {
                      $data[current($tokens[2])] = next($tokens[2]);
                      next($tokens[2]);
                  }
              }
              // if we want only one message we can ignore everything else and just return
              if ($to === null && !is_array($from) && $tokens[0] == $from) {
                  // we still need to read all lines
                  while (!$this->readLine($tokens, $tag));
                  return $data;
              }
              $result[$tokens[0]] = $data;
          }
  
          if ($to === null && !is_array($from)) {
              /**
               * @see Zend_Mail_Protocol_Exception
               */
              // require_once 'Zend/Mail/Protocol/Exception.php';
              throw new Zend_Mail_Protocol_Exception('the single id was not found in response');
          }
  
          return $result;
      }
code: public function fetch($items, $from, $to = null)
      {
          if (is_array($from)) {
              $set = implode(',', $from);
          } else if ($to === null) {
              $set = (int)$from;
          } else if ($to === INF) {
              $set = (int)$from . ':*';
          } else {
              $set = (int)$from . ':' . (int)$to;
          }
  
          $items = (array)$items;
          $itemList = $this->escapeList($items);
  
          $this->sendRequest('FETCH', array($set, $itemList), $tag);
  
          $result = array();
          while (!$this->readLine($tokens, $tag)) {
              // ignore other responses
              if ($tokens[1] != 'FETCH') {
                  continue;
              }
              // ignore other messages
              if ($to === null && !is_array($from) && $tokens[0] != $from) {
                  continue;
              }
              // if we only want one item we return that one directly
              if (count($items) == 1) {
                  if ($tokens[2][0] == $items[0]) {
                      $data = $tokens[2][1];
                  } else {
                      // maybe the server send an other field we didn't wanted
                      $count = count($tokens[2]);
                      // we start with 2, because 0 was already checked
                      for ($i = 2; $i < $count; $i += 2) {
                          if ($tokens[2][$i] != $items[0]) {
                              continue;
                          }
                          $data = $tokens[2][$i + 1];
                          break;
                      }
                  }
              } else {
                  $data = array();
                  while (key($tokens[2]) !== null) {
                      $data[current($tokens[2])] = next($tokens[2]);
                      next($tokens[2]);
                  }
              }
              // if we want only one message we can ignore everything else and just return
              if ($to === null && !is_array($from) && $tokens[0] == $from) {
                  // we still need to read all lines
                  while (!$this->readLine($tokens, $tag));
                  return $data;
              }
              $result[$tokens[0]] = $data;
          }
  
          if ($to === null && !is_array($from)) {
              /**
               * @see Zend_Mail_Protocol_Exception
               */
              // require_once 'Zend/Mail/Protocol/Exception.php';
              throw new Zend_Mail_Protocol_Exception('the single id was not found in response');
          }
  
          return $result;
      }
code_tokens: public function fetch ( $ items , $ from , $ to = null ) { if ( is_array ( $ from ) ) { $ set = implode ( ',' , $ from ) ; } else if ( $ to === null ) { $ set = ( int ) $ from ; } else if ( $ to === INF ) { $ set = ( int ) $ from . ':*' ; } else { $ set = ( int ) $ from . ':' . ( int ) $ to ; } $ items = ( array ) $ items ; $ itemList = $ this -> escapeList ( $ items ) ; $ this -> sendRequest ( 'FETCH' , array ( $ set , $ itemList ) , $ tag ) ; $ result = array ( ) ; while ( ! $ this -> readLine ( $ tokens , $ tag ) ) { // ignore other responses if ( $ tokens [ 1 ] != 'FETCH' ) { continue ; } // ignore other messages if ( $ to === null && ! is_array ( $ from ) && $ tokens [ 0 ] != $ from ) { continue ; } // if we only want one item we return that one directly if ( count ( $ items ) == 1 ) { if ( $ tokens [ 2 ] [ 0 ] == $ items [ 0 ] ) { $ data = $ tokens [ 2 ] [ 1 ] ; } else { // maybe the server send an other field we didn't wanted $ count = count ( $ tokens [ 2 ] ) ; // we start with 2, because 0 was already checked for ( $ i = 2 ; $ i < $ count ; $ i += 2 ) { if ( $ tokens [ 2 ] [ $ i ] != $ items [ 0 ] ) { continue ; } $ data = $ tokens [ 2 ] [ $ i + 1 ] ; break ; } } } else { $ data = array ( ) ; while ( key ( $ tokens [ 2 ] ) !== null ) { $ data [ current ( $ tokens [ 2 ] ) ] = next ( $ tokens [ 2 ] ) ; next ( $ tokens [ 2 ] ) ; } } // if we want only one message we can ignore everything else and just return if ( $ to === null && ! is_array ( $ from ) && $ tokens [ 0 ] == $ from ) { // we still need to read all lines while ( ! $ this -> readLine ( $ tokens , $ tag ) ) ; return $ data ; } $ result [ $ tokens [ 0 ] ] = $ data ; } if ( $ to === null && ! is_array ( $ from ) ) { /**
               * @see Zend_Mail_Protocol_Exception
               */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception ( 'the single id was not found in response' ) ; } return $ result ; }
docstring: fetch one or more items of one or more messages
  
  @param  string|array $items items to fetch from message(s) as string (if only one item)
  or array of strings
  @param  int          $from  message for items or start message if $to !== null
  @param  int|null     $to    if null only one message ($from) is fetched, else it's the
  last message, INF means last message avaible
  @return string|array if only one item of one message is fetched it's returned as string
  if items of one message are fetched it's returned as (name => value)
  if one items of messages are fetched it's returned as (msgno => value)
  if items of messages are fetchted it's returned as (msgno => (name => value))
  @throws Zend_Mail_Protocol_Exception
docstring_tokens: fetch one or more items of one or more messages