original_string: protected static function generateId($elementName)
      {
          $stop      =  !self::getOption('id_force_append_index');
          $tokens    =  strlen($elementName)
                        ? explode('[', str_replace(']', '', $elementName))
                        : ($stop? array('qfauto', ''): array('qfauto'));
          $container =& self::$ids;
          $id        =  '';
  
          do {
              $token = array_shift($tokens);
              // Handle the 'array[]' names
              if ('' === $token) {
                  if (empty($container)) {
                      $token = 0;
                  } else {
                      $keys  = array_keys($container);
                      $token = end($keys);
                      while (isset($container[$token])) {
                          $token++;
                      }
                  }
              }
              $id .= '-' . $token;
              if (!isset($container[$token])) {
                  $container[$token] = array();
              // Handle duplicate names when not having mandatory indexes
              } elseif (empty($tokens) && $stop) {
                  $tokens[] = '';
              }
              // Handle mandatory indexes
              if (empty($tokens) && !$stop) {
                  $tokens[] = '';
                  $stop     = true;
              }
              $container =& $container[$token];
          } while (!empty($tokens));
  
          return substr($id, 1);
      }
code: protected static function generateId($elementName)
      {
          $stop      =  !self::getOption('id_force_append_index');
          $tokens    =  strlen($elementName)
                        ? explode('[', str_replace(']', '', $elementName))
                        : ($stop? array('qfauto', ''): array('qfauto'));
          $container =& self::$ids;
          $id        =  '';
  
          do {
              $token = array_shift($tokens);
              // Handle the 'array[]' names
              if ('' === $token) {
                  if (empty($container)) {
                      $token = 0;
                  } else {
                      $keys  = array_keys($container);
                      $token = end($keys);
                      while (isset($container[$token])) {
                          $token++;
                      }
                  }
              }
              $id .= '-' . $token;
              if (!isset($container[$token])) {
                  $container[$token] = array();
              // Handle duplicate names when not having mandatory indexes
              } elseif (empty($tokens) && $stop) {
                  $tokens[] = '';
              }
              // Handle mandatory indexes
              if (empty($tokens) && !$stop) {
                  $tokens[] = '';
                  $stop     = true;
              }
              $container =& $container[$token];
          } while (!empty($tokens));
  
          return substr($id, 1);
      }
code_tokens: protected static function generateId ( $ elementName ) { $ stop = ! self :: getOption ( 'id_force_append_index' ) ; $ tokens = strlen ( $ elementName ) ? explode ( '[' , str_replace ( ']' , '' , $ elementName ) ) : ( $ stop ? array ( 'qfauto' , '' ) : array ( 'qfauto' ) ) ; $ container = & self :: $ ids ; $ id = '' ; do { $ token = array_shift ( $ tokens ) ; // Handle the 'array[]' names if ( '' === $ token ) { if ( empty ( $ container ) ) { $ token = 0 ; } else { $ keys = array_keys ( $ container ) ; $ token = end ( $ keys ) ; while ( isset ( $ container [ $ token ] ) ) { $ token ++ ; } } } $ id .= '-' . $ token ; if ( ! isset ( $ container [ $ token ] ) ) { $ container [ $ token ] = array ( ) ; // Handle duplicate names when not having mandatory indexes } elseif ( empty ( $ tokens ) && $ stop ) { $ tokens [ ] = '' ; } // Handle mandatory indexes if ( empty ( $ tokens ) && ! $ stop ) { $ tokens [ ] = '' ; $ stop = true ; } $ container = & $ container [ $ token ] ; } while ( ! empty ( $ tokens ) ) ; return substr ( $ id , 1 ) ; }
docstring: Generates an id for the element
  
  Called when an element is created without explicitly given id
  
  @param  string   Element name
  @return string   The generated element id
docstring_tokens: Generates an id for the element