original_string: protected static function normalizePath($path)
      {
          $pathAry = explode('/', $path);
          $i       = 1;
  
          do {
              if ('.' == $pathAry[$i]) {
                  if ($i < count($pathAry) - 1) {
                      array_splice($pathAry, $i, 1);
                  } else {
                      $pathAry[$i] = '';
                      $i++;
                  }
  
              } elseif ('..' == $pathAry[$i]) {
                  if (1 == $i) {
                      array_splice($pathAry, 1, 1);
  
                  } elseif ('..' != $pathAry[$i - 1]) {
                      if ($i < count($pathAry) - 1) {
                          array_splice($pathAry, $i - 1, 2);
                          $i--;
                      } else {
                          array_splice($pathAry, $i - 1, 2, '');
                      }
                  }
  
              } else {
                  $i++;
              }
          } while ($i < count($pathAry));
  
          return implode('/', $pathAry);
      }
code: protected static function normalizePath($path)
      {
          $pathAry = explode('/', $path);
          $i       = 1;
  
          do {
              if ('.' == $pathAry[$i]) {
                  if ($i < count($pathAry) - 1) {
                      array_splice($pathAry, $i, 1);
                  } else {
                      $pathAry[$i] = '';
                      $i++;
                  }
  
              } elseif ('..' == $pathAry[$i]) {
                  if (1 == $i) {
                      array_splice($pathAry, 1, 1);
  
                  } elseif ('..' != $pathAry[$i - 1]) {
                      if ($i < count($pathAry) - 1) {
                          array_splice($pathAry, $i - 1, 2);
                          $i--;
                      } else {
                          array_splice($pathAry, $i - 1, 2, '');
                      }
                  }
  
              } else {
                  $i++;
              }
          } while ($i < count($pathAry));
  
          return implode('/', $pathAry);
      }
code_tokens: protected static function normalizePath ( $ path ) { $ pathAry = explode ( '/' , $ path ) ; $ i = 1 ; do { if ( '.' == $ pathAry [ $ i ] ) { if ( $ i < count ( $ pathAry ) - 1 ) { array_splice ( $ pathAry , $ i , 1 ) ; } else { $ pathAry [ $ i ] = '' ; $ i ++ ; } } elseif ( '..' == $ pathAry [ $ i ] ) { if ( 1 == $ i ) { array_splice ( $ pathAry , 1 , 1 ) ; } elseif ( '..' != $ pathAry [ $ i - 1 ] ) { if ( $ i < count ( $ pathAry ) - 1 ) { array_splice ( $ pathAry , $ i - 1 , 2 ) ; $ i -- ; } else { array_splice ( $ pathAry , $ i - 1 , 2 , '' ) ; } } } else { $ i ++ ; } } while ( $ i < count ( $ pathAry ) ) ; return implode ( '/' , $ pathAry ) ; }
docstring: Removes the '..' and '.' segments from the path component
  
  @param    string  Path component of the URL, possibly with '.' and '..' segments
  @return   string  Path component of the URL with '.' and '..' segments removed
docstring_tokens: Removes the .. and . segments from the path component