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

        // If on Window, try to parse drive.
        if (self::myIsWindows()) {
            $driveAndPath = explode(':', $path, 2);

            if (count($driveAndPath) === 2) {
                $drive = $driveAndPath[0];
                if (!self::myDriveValidator($drive, $error)) {
                    return false;
                }

                $drive = strtoupper($drive);
                $path = $driveAndPath[1];
            }
        }

        $result = self::myParse(
            $directorySeparator,
            DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path,
            $partValidator,
            $stringDecoder,
            $isAbsolute,
            $aboveBaseLevel,
            $directoryParts,
            $filename,
            $error
        );

        // File path containing a drive and relative path is invalid.
        if ($drive !== null && !$isAbsolute) {
            $error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".';

            return false;
        }

        return $result;
    }
private static function myFilePathParse(string $directorySeparator, string $path, callable $partValidator, callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?string &$drive = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
    {
        $drive = null;

        // If on Window, try to parse drive.
        if (self::myIsWindows()) {
            $driveAndPath = explode(':', $path, 2);

            if (count($driveAndPath) === 2) {
                $drive = $driveAndPath[0];
                if (!self::myDriveValidator($drive, $error)) {
                    return false;
                }

                $drive = strtoupper($drive);
                $path = $driveAndPath[1];
            }
        }

        $result = self::myParse(
            $directorySeparator,
            DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path,
            $partValidator,
            $stringDecoder,
            $isAbsolute,
            $aboveBaseLevel,
            $directoryParts,
            $filename,
            $error
        );

        // File path containing a drive and relative path is invalid.
        if ($drive !== null && !$isAbsolute) {
            $error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".';

            return false;
        }

        return $result;
    }
private static function myFilePathParse ( string $ directorySeparator , string $ path , callable $ partValidator , callable $ stringDecoder = null , ? bool & $ isAbsolute = null , ? int & $ aboveBaseLevel = null , ? string & $ drive = null , ? array & $ directoryParts = null , ? string & $ filename = null , ? string & $ error = null ) : bool { $ drive = null ; // If on Window, try to parse drive. if ( self :: myIsWindows ( ) ) { $ driveAndPath = explode ( ':' , $ path , 2 ) ; if ( count ( $ driveAndPath ) === 2 ) { $ drive = $ driveAndPath [ 0 ] ; if ( ! self :: myDriveValidator ( $ drive , $ error ) ) { return false ; } $ drive = strtoupper ( $ drive ) ; $ path = $ driveAndPath [ 1 ] ; } } $ result = self :: myParse ( $ directorySeparator , DIRECTORY_SEPARATOR !== '\'' ? str_replace ( '/' , DIRECTORY_SEPARATOR , $ path ) : $ path , $ partValidator , $ stringDecoder , $ isAbsolute , $ aboveBaseLevel , $ directoryParts , $ filename , $ error ) ; // File path containing a drive and relative path is invalid. if ( $ drive !== null && ! $ isAbsolute ) { $ error = 'Path can not contain drive "' . $ drive . '" and non-absolute path "' . $ path . '".' ; return false ; } return $ result ; }
Tries to parse a file path and returns the result or error text.

@param string        $directorySeparator The directory separator.
@param string        $path               The path.
@param callable      $partValidator      The part validator.
@param callable      $stringDecoder      The string decoding function or null if parts should not be decoded.
@param bool|null     $isAbsolute         Whether the path is absolute or relative is parsing was successful, undefined otherwise.
@param int|null      $aboveBaseLevel     The number of directory parts above base level if parsing was successful, undefined otherwise.
@param string|null   $drive              The drive or null if parsing was successful, undefined otherwise
@param string[]|null $directoryParts     The directory parts if parsing was successful, undefined otherwise.
@param string|null   $filename           The file or null if parsing was not successful, undefined otherwise.
@param string|null   $error              The error text if validation was not successful, undefined otherwise.

@return bool True if parsing was successful, false otherwise.
Tries to parse a file path and returns the result or error text .