private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool
    {
        if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) {
            $error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool
    {
        if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) {
            $error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
private static function myPartValidator ( string $ part , bool $ isDirectory , ? string & $ error ) : bool { if ( preg_match ( self :: myIsWindows ( ) ? '/[\0<>:*?"|]+/' : '/[\0]+/' , $ part , $ matches ) ) { $ error = ( $ isDirectory ? 'Part of directory' : 'Filename' ) . ' "' . $ part . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } return true ; }
Validates a directory part name or a file name.

@param string      $part        The part to validate.
@param bool        $isDirectory If true part is a directory part name, if false part is a file name.
@param string|null $error       The error text if validation was not successful, undefined otherwise.

@return bool True if validation was successful, false otherwise.
Validates a directory part name or a file name .