original_string: public static function getArrayFromQueryString($urlQuery)
      {
          if (strlen($urlQuery) == 0) {
              return array();
          }
  
          // TODO: this method should not use a cache. callers should instead have their own cache, configured through DI.
          //       one undesirable side effect of using a cache here, is that this method can now init the StaticContainer, which makes setting
          //       test environment for RequestCommand more complicated.
          $cache    = Cache::getTransientCache();
          $cacheKey = 'arrayFromQuery' . $urlQuery;
  
          if ($cache->contains($cacheKey)) {
              return $cache->fetch($cacheKey);
          }
  
          if ($urlQuery[0] == '?') {
              $urlQuery = substr($urlQuery, 1);
          }
          $separator = '&';
  
          $urlQuery = $separator . $urlQuery;
          //		$urlQuery = str_replace(array('%20'), ' ', $urlQuery);
          $referrerQuery = trim($urlQuery);
  
          $values = explode($separator, $referrerQuery);
  
          $nameToValue = array();
  
          foreach ($values as $value) {
              $pos = strpos($value, '=');
              if ($pos !== false) {
                  $name = substr($value, 0, $pos);
                  $value = substr($value, $pos + 1);
                  if ($value === false) {
                      $value = '';
                  }
              } else {
                  $name = $value;
                  $value = false;
              }
              if (!empty($name)) {
                  $name = Common::sanitizeInputValue($name);
              }
              if (!empty($value)) {
                  $value = Common::sanitizeInputValue($value);
              }
  
              // if array without indexes
              $count = 0;
              $tmp = preg_replace('/(\[|%5b)(]|%5d)$/i', '', $name, -1, $count);
              if (!empty($tmp) && $count) {
                  $name = $tmp;
                  if (isset($nameToValue[$name]) == false || is_array($nameToValue[$name]) == false) {
                      $nameToValue[$name] = array();
                  }
                  array_push($nameToValue[$name], $value);
              } elseif (!empty($name)) {
                  $nameToValue[$name] = $value;
              }
          }
  
          $cache->save($cacheKey, $nameToValue);
  
          return $nameToValue;
      }
code: public static function getArrayFromQueryString($urlQuery)
      {
          if (strlen($urlQuery) == 0) {
              return array();
          }
  
          // TODO: this method should not use a cache. callers should instead have their own cache, configured through DI.
          //       one undesirable side effect of using a cache here, is that this method can now init the StaticContainer, which makes setting
          //       test environment for RequestCommand more complicated.
          $cache    = Cache::getTransientCache();
          $cacheKey = 'arrayFromQuery' . $urlQuery;
  
          if ($cache->contains($cacheKey)) {
              return $cache->fetch($cacheKey);
          }
  
          if ($urlQuery[0] == '?') {
              $urlQuery = substr($urlQuery, 1);
          }
          $separator = '&';
  
          $urlQuery = $separator . $urlQuery;
          //		$urlQuery = str_replace(array('%20'), ' ', $urlQuery);
          $referrerQuery = trim($urlQuery);
  
          $values = explode($separator, $referrerQuery);
  
          $nameToValue = array();
  
          foreach ($values as $value) {
              $pos = strpos($value, '=');
              if ($pos !== false) {
                  $name = substr($value, 0, $pos);
                  $value = substr($value, $pos + 1);
                  if ($value === false) {
                      $value = '';
                  }
              } else {
                  $name = $value;
                  $value = false;
              }
              if (!empty($name)) {
                  $name = Common::sanitizeInputValue($name);
              }
              if (!empty($value)) {
                  $value = Common::sanitizeInputValue($value);
              }
  
              // if array without indexes
              $count = 0;
              $tmp = preg_replace('/(\[|%5b)(]|%5d)$/i', '', $name, -1, $count);
              if (!empty($tmp) && $count) {
                  $name = $tmp;
                  if (isset($nameToValue[$name]) == false || is_array($nameToValue[$name]) == false) {
                      $nameToValue[$name] = array();
                  }
                  array_push($nameToValue[$name], $value);
              } elseif (!empty($name)) {
                  $nameToValue[$name] = $value;
              }
          }
  
          $cache->save($cacheKey, $nameToValue);
  
          return $nameToValue;
      }
code_tokens: public static function getArrayFromQueryString ( $ urlQuery ) { if ( strlen ( $ urlQuery ) == 0 ) { return array ( ) ; } // TODO: this method should not use a cache. callers should instead have their own cache, configured through DI. //       one undesirable side effect of using a cache here, is that this method can now init the StaticContainer, which makes setting //       test environment for RequestCommand more complicated. $ cache = Cache :: getTransientCache ( ) ; $ cacheKey = 'arrayFromQuery' . $ urlQuery ; if ( $ cache -> contains ( $ cacheKey ) ) { return $ cache -> fetch ( $ cacheKey ) ; } if ( $ urlQuery [ 0 ] == '?' ) { $ urlQuery = substr ( $ urlQuery , 1 ) ; } $ separator = '&' ; $ urlQuery = $ separator . $ urlQuery ; //		$urlQuery = str_replace(array('%20'), ' ', $urlQuery); $ referrerQuery = trim ( $ urlQuery ) ; $ values = explode ( $ separator , $ referrerQuery ) ; $ nameToValue = array ( ) ; foreach ( $ values as $ value ) { $ pos = strpos ( $ value , '=' ) ; if ( $ pos !== false ) { $ name = substr ( $ value , 0 , $ pos ) ; $ value = substr ( $ value , $ pos + 1 ) ; if ( $ value === false ) { $ value = '' ; } } else { $ name = $ value ; $ value = false ; } if ( ! empty ( $ name ) ) { $ name = Common :: sanitizeInputValue ( $ name ) ; } if ( ! empty ( $ value ) ) { $ value = Common :: sanitizeInputValue ( $ value ) ; } // if array without indexes $ count = 0 ; $ tmp = preg_replace ( '/(\[|%5b)(]|%5d)$/i' , '' , $ name , - 1 , $ count ) ; if ( ! empty ( $ tmp ) && $ count ) { $ name = $ tmp ; if ( isset ( $ nameToValue [ $ name ] ) == false || is_array ( $ nameToValue [ $ name ] ) == false ) { $ nameToValue [ $ name ] = array ( ) ; } array_push ( $ nameToValue [ $ name ] , $ value ) ; } elseif ( ! empty ( $ name ) ) { $ nameToValue [ $ name ] = $ value ; } } $ cache -> save ( $ cacheKey , $ nameToValue ) ; return $ nameToValue ; }
docstring: Returns a URL query string as an array.
  
  @param string $urlQuery The query string, eg, `'?param1=value1&param2=value2'`.
  @return array eg, `array('param1' => 'value1', 'param2' => 'value2')`
  @api
docstring_tokens: Returns a URL query string as an array .