private static function myParse(string $directorySeparator, string $path, callable $partValidator, ?callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
    {
        $parts = explode($directorySeparator, $path);
        $partsCount = count($parts);

        $directoryParts = [];
        $filename = null;
        $isAbsolute = false;
        $aboveBaseLevel = 0;
        $index = 0;

        // If the first part is empty and other parts follow, the path begins with directory separator and is therefore absolute.
        if ($partsCount > 1 && $parts[0] === '') {
            $isAbsolute = true;
            $index++;
        }

        // Go through all parts.
        for (; $index < $partsCount; $index++) {
            if (!self::myParsePart($parts[$index], $index === $partsCount - 1, $partValidator, $stringDecoder, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
                return false;
            }
        }

        return true;
    }