original_string: private static function removeDotSegments(string $path)
      {
          $result = '';
  
          while (!\in_array($path, ['', '.', '..'], true)) {
              if ('.' === $path[0] && (0 === strpos($path, $p = '../') || 0 === strpos($path, $p = './'))) {
                  $path = substr($path, \strlen($p));
              } elseif ('/.' === $path || 0 === strpos($path, '/./')) {
                  $path = substr_replace($path, '/', 0, 3);
              } elseif ('/..' === $path || 0 === strpos($path, '/../')) {
                  $i = strrpos($result, '/');
                  $result = $i ? substr($result, 0, $i) : '';
                  $path = substr_replace($path, '/', 0, 4);
              } else {
                  $i = strpos($path, '/', 1) ?: \strlen($path);
                  $result .= substr($path, 0, $i);
                  $path = substr($path, $i);
              }
          }
  
          return $result;
      }
code: private static function removeDotSegments(string $path)
      {
          $result = '';
  
          while (!\in_array($path, ['', '.', '..'], true)) {
              if ('.' === $path[0] && (0 === strpos($path, $p = '../') || 0 === strpos($path, $p = './'))) {
                  $path = substr($path, \strlen($p));
              } elseif ('/.' === $path || 0 === strpos($path, '/./')) {
                  $path = substr_replace($path, '/', 0, 3);
              } elseif ('/..' === $path || 0 === strpos($path, '/../')) {
                  $i = strrpos($result, '/');
                  $result = $i ? substr($result, 0, $i) : '';
                  $path = substr_replace($path, '/', 0, 4);
              } else {
                  $i = strpos($path, '/', 1) ?: \strlen($path);
                  $result .= substr($path, 0, $i);
                  $path = substr($path, $i);
              }
          }
  
          return $result;
      }
code_tokens: private static function removeDotSegments ( string $ path ) { $ result = '' ; while ( ! \ in_array ( $ path , [ '' , '.' , '..' ] , true ) ) { if ( '.' === $ path [ 0 ] && ( 0 === strpos ( $ path , $ p = '../' ) || 0 === strpos ( $ path , $ p = './' ) ) ) { $ path = substr ( $ path , \ strlen ( $ p ) ) ; } elseif ( '/.' === $ path || 0 === strpos ( $ path , '/./' ) ) { $ path = substr_replace ( $ path , '/' , 0 , 3 ) ; } elseif ( '/..' === $ path || 0 === strpos ( $ path , '/../' ) ) { $ i = strrpos ( $ result , '/' ) ; $ result = $ i ? substr ( $ result , 0 , $ i ) : '' ; $ path = substr_replace ( $ path , '/' , 0 , 4 ) ; } else { $ i = strpos ( $ path , '/' , 1 ) ? : \ strlen ( $ path ) ; $ result .= substr ( $ path , 0 , $ i ) ; $ path = substr ( $ path , $ i ) ; } } return $ result ; }
docstring: Removes dot-segments from a path.
  
  @see https://tools.ietf.org/html/rfc3986#section-5.2.4
docstring_tokens: Removes dot - segments from a path .