original_string: protected function searchByFlag( $flag )
      {
          $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID;
  
          if ( $this->state != self::STATE_SELECTED &&
               $this->state != self::STATE_SELECTED_READONLY )
          {
              throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." );
          }
  
          $matchingMessages = array();
          $flag = $this->normalizeFlag( $flag );
          if ( in_array( $flag, self::$extendedFlags ) )
          {
              $tag = $this->getNextTag();
              $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" );
              $response = $this->getResponse( '* SEARCH' );
  
              if ( strpos( $response, '* SEARCH' ) !== false )
              {
                  $ids = substr( trim( $response ), 9 );
                  if ( trim( $ids ) !== "" )
                  {
                      $matchingMessages = explode( ' ', $ids );
                  }
              }
              $response = trim( $this->getResponse( $tag, $response ) );
              if ( $this->responseType( $response ) != self::RESPONSE_OK )
              {
                  throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." );
              }
          }
          else
          {
              throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." );
          }
          return $matchingMessages;
      }
code: protected function searchByFlag( $flag )
      {
          $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID;
  
          if ( $this->state != self::STATE_SELECTED &&
               $this->state != self::STATE_SELECTED_READONLY )
          {
              throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." );
          }
  
          $matchingMessages = array();
          $flag = $this->normalizeFlag( $flag );
          if ( in_array( $flag, self::$extendedFlags ) )
          {
              $tag = $this->getNextTag();
              $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" );
              $response = $this->getResponse( '* SEARCH' );
  
              if ( strpos( $response, '* SEARCH' ) !== false )
              {
                  $ids = substr( trim( $response ), 9 );
                  if ( trim( $ids ) !== "" )
                  {
                      $matchingMessages = explode( ' ', $ids );
                  }
              }
              $response = trim( $this->getResponse( $tag, $response ) );
              if ( $this->responseType( $response ) != self::RESPONSE_OK )
              {
                  throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." );
              }
          }
          else
          {
              throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." );
          }
          return $matchingMessages;
      }
code_tokens: protected function searchByFlag ( $ flag ) { $ uid = ( $ this -> options -> uidReferencing ) ? self :: UID : self :: NO_UID ; if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." ) ; } $ matchingMessages = array ( ) ; $ flag = $ this -> normalizeFlag ( $ flag ) ; if ( in_array ( $ flag , self :: $ extendedFlags ) ) { $ tag = $ this -> getNextTag ( ) ; $ this -> connection -> sendData ( "{$tag} {$uid}SEARCH ({$flag})" ) ; $ response = $ this -> getResponse ( '* SEARCH' ) ; if ( strpos ( $ response , '* SEARCH' ) !== false ) { $ ids = substr ( trim ( $ response ) , 9 ) ; if ( trim ( $ ids ) !== "" ) { $ matchingMessages = explode ( ' ' , $ ids ) ; } } $ response = trim ( $ this -> getResponse ( $ tag , $ response ) ) ; if ( $ this -> responseType ( $ response ) != self :: RESPONSE_OK ) { throw new ezcMailTransportException ( "The IMAP server could not search the messages by flags: {$response}." ) ; } } else { throw new ezcMailTransportException ( "Flag '{$flag}' is not allowed for searching." ) ; } return $ matchingMessages ; }
docstring: Returns an array of message numbers from the selected mailbox which have a
  certain flag set.
  
  This method supports unique IDs instead of message numbers. See
  {@link ezcMailImapTransportOptions} for how to enable unique IDs
  referencing.
  
  $flag can be one of:
  
  Basic flags:
  - ANSWERED   - message has been answered
  - DELETED    - message is marked to be deleted by later EXPUNGE
  - DRAFT      - message is marked as a draft
  - FLAGGED    - message is "flagged" for urgent/special attention
  - RECENT     - message is recent
  - SEEN       - message has been read
  
  Opposites of the above flags:
  - UNANSWERED
  - UNDELETED
  - UNDRAFT
  - UNFLAGGED
  - OLD
  - UNSEEN
  
  Composite flags:
  - NEW        - equivalent to RECENT + UNSEEN
  - ALL        - all the messages
  
  The returned array is something like this:
  <code>
  array( 0 => 1, 1 => 5 );
  </code>
  
  Before calling this method, a connection to the IMAP server must be
  established and a user must be authenticated successfully, and a mailbox
  must be selected.
  
  @throws ezcMailTransportException
  if a mailbox is not selected
  or if the server sent a negative response
  or if $flag is not valid
  @param string $flag
  @return array(int)
docstring_tokens: Returns an array of message numbers from the selected mailbox which have a certain flag set .