code: private static function filterPath(?string $path): ?string
      {
          if ($path === null) {
              return null;
          }
  
          /** @link https://tools.ietf.org/html/rfc3986#section-3.3 */
          return preg_replace_callback(
              '/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
              function ($match) {
                  return rawurlencode($match[0]);
              },
              $path
          );
      }
docs: Filters the URI path and percent-encodes reserved characters
  
  @param string|null $path The path to filter if one is set, otherwise null
  @return string|null The filtered path, or null if the path was already null