original_string: private function connect(array &$connections)
      {
          $exceptions = [];
          while (count($connections) > 0) {
              /** @var Connection $connection */
              $connection = array_pop($connections);
  
              try {
                  if ($connection->open()) {
                      return $connection;
                  }
              } catch (DatabaseException $e) {
                  $exceptions[] = $e->getMessage();
              }
          }
  
          throw new ConnectionException(
              'Unable to select connection.',
              '',
              0,
              count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
          );
      }
code: private function connect(array &$connections)
      {
          $exceptions = [];
          while (count($connections) > 0) {
              /** @var Connection $connection */
              $connection = array_pop($connections);
  
              try {
                  if ($connection->open()) {
                      return $connection;
                  }
              } catch (DatabaseException $e) {
                  $exceptions[] = $e->getMessage();
              }
          }
  
          throw new ConnectionException(
              'Unable to select connection.',
              '',
              0,
              count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
          );
      }
code_tokens: private function connect ( array & $ connections ) { $ exceptions = [ ] ; while ( count ( $ connections ) > 0 ) { /** @var Connection $connection */ $ connection = array_pop ( $ connections ) ; try { if ( $ connection -> open ( ) ) { return $ connection ; } } catch ( DatabaseException $ e ) { $ exceptions [ ] = $ e -> getMessage ( ) ; } } throw new ConnectionException ( 'Unable to select connection.' , '' , 0 , count ( $ exceptions ) > 0 ? new ConnectionException ( implode ( ' ' , $ exceptions ) ) : null ) ; }
docstring: Calls the connect method for every connection in the given array and returns the connection on success.
  
  @param Connection[] $connections
  
  @throws ConnectionException
  
  @return Connection
docstring_tokens: Calls the connect method for every connection in the given array and returns the connection on success .