<?php

declare(strict_types=1);
/**
 * @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace OCA\Files_Trashbin\Trash {
	use OCP\Files\Node;
	use OCP\Files\Storage\IStorage;
	use OCP\IUser;
	use OCP\Files\FileInfo;

	interface ITrashManager {
		public function pauseTrash();

		public function resumeTrash();
	}

	interface ITrashBackend {
		/**
		 * @return ITrashItem[]
		 */
		public function listTrashRoot(IUser $user): array;

		/**
		 * @return ITrashItem[]
		 */
		public function listTrashFolder(ITrashItem $folder): array;

		/**
		 * @param ITrashItem $item
		 */
		public function restoreItem(ITrashItem $item);

		public function removeItem(ITrashItem $item);

		public function moveToTrash(IStorage $storage, string $internalPath): bool;

		/**
		 * @return Node|null
		 */
		public function getTrashNodeById(IUser $user, int $fileId);
	}

	interface ITrashItem extends FileInfo {
		public function getTrashBackend(): ITrashBackend;
	
		public function getOriginalLocation(): string;
	
		public function getDeletedTime(): int;
	
		public function getTrashPath(): string;
	
		public function isRootItem(): bool;
	
		public function getUser(): IUser;

		public function getTitle(): string;
	}

	class TrashItem implements ITrashItem {
		public function getTrashBackend(): ITrashBackend {
			throw new \Exception('stub');
		}

		public function getOriginalLocation(): string {
			throw new \Exception('stub');
		}

		public function getDeletedTime(): int {
			throw new \Exception('stub');
		}

		public function getTrashPath(): string {
			throw new \Exception('stub');
		}

		public function isRootItem(): bool {
			throw new \Exception('stub');
		}

		public function getUser(): IUser {
			throw new \Exception('stub');
		}

		public function getEtag() {
		}

		public function getId() {
		}

		public function getSize($includeMounts = true) {
			throw new \Exception('stub');
		}

		public function getMtime() {
			throw new \Exception('stub');
		}

		public function getName() {
			throw new \Exception('stub');
		}

		public function getInternalPath() {
			throw new \Exception('stub');
		}

		public function getPath() {
			throw new \Exception('stub');
		}

		public function getMimetype() {
			throw new \Exception('stub');
		}

		public function getMimePart() {
			throw new \Exception('stub');
		}

		public function getStorage() {
			throw new \Exception('stub');
		}

		public function isEncrypted() {
			throw new \Exception('stub');
		}

		public function getPermissions() {
			throw new \Exception('stub');
		}

		public function getType() {
			throw new \Exception('stub');
		}

		public function isReadable() {
			throw new \Exception('stub');
		}

		public function isUpdateable() {
			throw new \Exception('stub');
		}

		public function isCreatable() {
			throw new \Exception('stub');
		}

		public function isDeletable() {
			throw new \Exception('stub');
		}

		public function isShareable() {
			throw new \Exception('stub');
		}

		public function isShared() {
			throw new \Exception('stub');
		}

		public function isMounted() {
			throw new \Exception('stub');
		}

		public function getMountPoint() {
			throw new \Exception('stub');
		}

		public function getOwner() {
			throw new \Exception('stub');
		}

		public function getChecksum() {
			throw new \Exception('stub');
		}

		public function getExtension(): string {
			throw new \Exception('stub');
		}

		public function getTitle(): string {
			throw new \Exception('stub');
		}

		public function getCreationTime(): int {
			throw new \Exception('stub');
		}

		public function getUploadTime(): int {
			throw new \Exception('stub');
		}
	}
}

namespace OCA\Files_Trashbin {
	class Expiration {

		public const DEFAULT_RETENTION_OBLIGATION = 30;
		public const NO_OBLIGATION = -1;

		public function setRetentionObligation(string $obligation) {}

		/** @return bool */
		public function isEnabled() {}

		/**
		 * @param int $timestamp
		 * @param bool $quotaExceeded
		 * @return bool
		 */
		public function isExpired($timestamp, $quotaExceeded = false) {}
	}
}


namespace OCA\Files_Versions\Versions {
	use OCP\Files\File;
	use OCP\Files\FileInfo;
	use OCP\Files\NotFoundException;
	use OCP\Files\Storage\IStorage;
	use OCP\IUser;

	interface IVersionBackend {
		public function useBackendForStorage(IStorage $storage): bool;

		/**
		 * @return IVersion[]
		 */
		public function getVersionsForFile(IUser $user, FileInfo $file): array;

		public function createVersion(IUser $user, FileInfo $file);

		public function rollback(IVersion $version);

		/**
		 * @return resource|false
		 * @throws NotFoundException
		 */
		public function read(IVersion $version);

		/**
		 * @param int|string $revision
		 */
		public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): ?File;
	}

	interface IVersion {
		public function getBackend(): IVersionBackend;

		public function getSourceFile(): FileInfo;

		/**
		 * @return int|string
		 */
		public function getRevisionId();

		public function getTimestamp(): int;

		public function getSize(): int;

		public function getSourceFileName(): string;

		public function getMimeType(): string;

		public function getVersionPath(): string;

		public function getUser(): IUser;
	}

	class Version implements IVersion {
		public function __construct(
			int $timestamp,
			$revisionId,
			string $name,
			int $size,
			string $mimetype,
			string $path,
			FileInfo $sourceFileInfo,
			IVersionBackend $backend,
			IUser $user
		) {
		}

		public function getBackend(): IVersionBackend {
			throw new \Exception('stub');
		}

		public function getSourceFile(): FileInfo {
			throw new \Exception('stub');
		}

		public function getRevisionId() {
			throw new \Exception('stub');
		}

		public function getTimestamp(): int {
			throw new \Exception('stub');
		}

		public function getSize(): int {
			throw new \Exception('stub');
		}

		public function getSourceFileName(): string {
			throw new \Exception('stub');
		}

		public function getMimeType(): string {
			throw new \Exception('stub');
		}

		public function getVersionPath(): string {
			throw new \Exception('stub');
		}

		public function getUser(): IUser {
			throw new \Exception('stub');
		}
	}
}

namespace OCA\Files_Versions {
	class Expiration {
		// how long do we keep files a version if no other value is defined in the config file (unit: days)
		public const NO_OBLIGATION = -1;
		/** @return bool */
		public function isEnabled() {}

		public function shouldAutoExpire() { }

		/**
		 * @param int $timestamp
		 * @param bool $quotaExceeded
		 * @return bool
		 */
		public function isExpired($timestamp, $quotaExceeded = false) {}

		/** @return int */
		public function getMaxAgeAsTimestamp() {}
	}
}

namespace {

	use OCP\IServerContainer;

	class OC {
		static $CLI = false;
		/** @var IServerContainer */
		static $server;
	}
}

namespace OC\Files\Node {
	use OCP\Files\FileInfo;
	abstract class Node implements \OCP\Files\Node {
		/** @return FileInfo|\ArrayAccess */
		public function getFileInfo() {}

		/** @return \OCP\Files\Mount\IMountPoint */
		public function getMountPoint() {}
	}
}

namespace OC\Hooks {
	class Emitter {
		public function emit(string $class, string $value, array $option) {}
		/** Closure $closure */
		public function listen(string $class, string $value, $closure) {}
	}
	class BasicEmitter extends Emitter {
	}
}

namespace OC\Cache {
	class CappedMemoryCache {
		public function get($key) {}
		public function set($key, $value, $ttl = '') {}
	}
}

namespace OC\Core\Command {
	use Symfony\Component\Console\Input\InputInterface;
	use Symfony\Component\Console\Output\OutputInterface;
	class Base {
		public const OUTPUT_FORMAT_PLAIN = 'plain';
		public const OUTPUT_FORMAT_JSON = 'json';
		public const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty';

		public function __construct() {}
		protected function configure() {}
		public function run(InputInterface $input, OutputInterface $output) {}
		public function setName(string $name) {}
		public function getHelper(string $name) {}
		protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = '  - ') {
		}
	}
}

namespace OC\Files\ObjectStore {
	class NoopScanner {}
}

namespace Symfony\Component\Console\Helper {
	use Symfony\Component\Console\Output\OutputInterface;
	class Table {
		public function __construct(OutputInterface $text) {}
		public function setHeaders(array $header) {}
		public function setRows(array $rows) {}
		public function render() {}
		public function appendRow(array $row) {}
	}
}

namespace Symfony\Component\Console\Input {
	class InputInterface {
		public function getOption(string $key) {}
		public function getArgument(string $key) {}
	}
	class InputArgument {
		const REQUIRED = 0;
		const OPTIONAL = 1;
		const IS_ARRAY = 1;
	}
	class InputOption {
		const VALUE_NONE = 1;
		const VALUE_REQUIRED = 1;
		const VALUE_OPTIONAL = 1;
	}
}

namespace Symfony\Component\Console\Question {
	class ConfirmationQuestion {
		public function __construct(string $text, bool $default, string $accept = 'y') {}
	}
}

namespace Symfony\Component\Console\Output {
	class OutputInterface {
		public const VERBOSITY_VERBOSE = 1;
		public function writeln(string $text, int $flat = 0) {}
		public function write(string $text, int $flat = 0) {}
	}
}

namespace OC\User {
    class NoUserException extends \Exception {}
}

namespace OC\DB {
    use OCP\IDBConnection;
    class ConnectionAdapter {}

    class SchemaWrapper {
        public function __construct(IDBConnection $connection) {}

        public function performDropTableCalls();
    }
}

namespace OC {
    class SystemConfig {}
}

namespace Doctrine\DBAL\Query {
    class QueryBuilder {
        public const SELECT = 'select';
    }
}

namespace OC\DB\QueryBuilder {
    use OCP\DB\IResult;
    use OCP\DB\QueryBuilder\ICompositeExpression;
    use OCP\DB\QueryBuilder\ILiteral;
    use OCP\DB\QueryBuilder\IParameter;
    use OCP\DB\QueryBuilder\IQueryBuilder;
    use OCP\DB\QueryBuilder\IQueryFunction;
    use Psr\Log\LoggerInterface;

    class QueryBuilder implements IQueryBuilder {
        public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, LoggerInterface $logger) {
        }
        public function automaticTablePrefix($enabled) { }
        public function expr() { }
        public function func() { }
        public function getType() { }
        public function getConnection() { }
        public function getState() { }
        public function execute() { }
        public function executeQuery(): IResult { }
        public function executeUpdate(): int { }
        public function executeStatement(): int { }
        public function getSQL() { }
        public function setParameter($key, $value, $type = null) { }
        public function setParameters(array $params, array $types = []) { }
        public function getParameters() { }
        public function getParameter($key) { }
        public function getParameterTypes() { }
        public function getParameterType($key) { }
        public function setFirstResult($firstResult) { }
        public function getFirstResult() { }
        public function setMaxResults($maxResults) { }
        public function getMaxResults() { }
        public function select(...$selects) { }
        public function selectAlias($select, $alias) { }
        public function selectDistinct($select) { }
        public function addSelect(...$selects) { }
        public function delete($delete = null, $alias = null) { }
        public function update($update = null, $alias = null) { }
        public function insert($insert = null) { }
        public function from($from, $alias = null) { }
        public function join($fromAlias, $join, $alias, $condition = null) { }
        public function innerJoin($fromAlias, $join, $alias, $condition = null) { }
        public function leftJoin($fromAlias, $join, $alias, $condition = null) { }
        public function rightJoin($fromAlias, $join, $alias, $condition = null) { }
        public function set($key, $value) { }
        public function where(...$predicates) { }
        public function andWhere(...$where) { }
        public function orWhere(...$where) { }
        public function groupBy(...$groupBys) { }
        public function addGroupBy(...$groupBys) { }
        public function setValue($column, $value) { }
        public function values(array $values) { }
        public function having(...$having) { }
        public function andHaving(...$having) { }
        public function orHaving(...$having) { }
        public function orderBy($sort, $order = null) { }
        public function addOrderBy($sort, $order = null) { }
        public function getQueryPart($queryPartName) { }
        public function getQueryParts() { }
        public function resetQueryParts($queryPartNames = null) { }
        public function resetQueryPart($queryPartName) { }
        public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) { }
        public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) { }
        public function createParameter($name) { }
        public function createFunction($call) { }
        public function getLastInsertId(): int { }
        public function getTableName($table) { }
        protected function prefixTableName($table) { }
        public function getColumnName($column, $tableAlias = '') { }
        public function quoteAlias($alias) { }
    }
}

namespace OC\Files\Cache {
	use OCP\Files\Cache\ICache;
	use OCP\Files\Cache\ICacheEntry;
	use OCP\Files\Search\ISearchQuery;
	use OCP\Files\Search\ISearchOperator;
	use OCP\Files\Search\ISearchQuery;
	use OCP\Files\IMimeTypeLoader;

	class Cache implements ICache {
		/**
		 * @param \OCP\Files\Cache\ICache $cache
		 */
		public function __construct($cache) {
			$this->cache = $cache;
		}
		public function getNumericStorageId() { }
		public function get() { }
		public function getIncomplete() {}
		public function getPathById($id) {}
		public function getAll() {}
		public function get($file) {}
		public function getFolderContents($folder) {}
		public function getFolderContentsById($fileId) {}
		public function put($file, array $data) {}
		public function insert($file, array $data) {}
		public function update($id, array $data) {}
		public function getId($file) {}
		public function getParentId($file) {}
		public function inCache($file) {}
		public function remove($file) {}
		public function move($source, $target) {}
		public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {}
		public function clear() {}
		public function getStatus($file) {}
		public function search($pattern) {}
		public function searchByMime($mimetype) {}
		public function searchQuery(ISearchQuery $query) {}
		public function correctFolderSize($path, $data = null, $isBackgroundScan = false) {}
		public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {}
		public function normalize($path) {}
		public function getQueryFilterForStorage(): ISearchOperator {}
		public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {}
		public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader): ICacheEntry {}
	}
}

namespace OC\Files\Cache\Wrapper {
	use OC\Files\Cache\Cache;
	class CacheWrapper extends Cache {}
}

namespace OC\Files {
	use OCP\Files\Cache\ICacheEntry;
	use OCP\Files\Mount\IMountPoint;
	use OCP\IUser;

	class Filesystem {
		public static function addStorageWrapper(string $wrapperName, callable $wrapper, int $priority = 50) {
		}
	}

	class FileInfo implements \OCP\Files\FileInfo {
		/**
		 * @param string|boolean $path
		 * @param \OCP\Files\Storage\IStorage $storage
		 * @param string $internalPath
		 * @param array|ICacheEntry $data
		 * @param \OCP\Files\Mount\IMountPoint $mount
		 * @param \OCP\IUser|null $owner
		 */
		public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {}
	}
	class View {
		public function __construct(string $path) {}
		public function unlink($path) {}
	}
}

namespace OC\User {
	use OCP\UserInterface;
	use OCP\IUser;
	use Symfony\Component\EventDispatcher\EventDispatcherInterface;
	class User implements IUser {
		public function __construct(string $uid, ?UserInterface $backend, EventDispatcherInterface $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) {}
	}
}

namespace OCA\DAV\Upload {

	use Sabre\DAV\File;

	abstract class FutureFile extends File {}
}

namespace OCA\DAV\Connector\Sabre {

	class Node {
		public function getFileInfo(): \OCP\Files\FileInfo {}
	}
}

namespace OC\BackgroundJob {

	use OCP\BackgroundJob\IJob;
	use OCP\BackgroundJob\IJobList;
	use OCP\ILogger;

	abstract class TimedJob implements IJob {
		public function execute(IJobList $jobList, ILogger $logger = null) {
		}

		abstract protected function run($argument);

		public function setId(int $id) {
		}

		public function setLastRun(int $lastRun) {
		}

		public function setArgument($argument) {
		}

		public function getId() {
		}

		public function getLastRun() {
		}

		public function getArgument() {
		}
	}
}

namespace OC\Files\Mount {
	use OC\Files\Filesystem;
	use OC\Files\Storage\Storage;
	use OC\Files\Storage\StorageFactory;
	use OCP\Files\Mount\IMountPoint;

	class MountPoint implements IMountPoint {
		/**
		 * @var \OC\Files\Storage\Storage $storage
		 */
		protected $storage = null;
		protected $class;
		protected $storageId;
		protected $rootId = null;
	
		/** @var int|null */
		protected $mountId;
	
		/**
		 * @param string|\OCP\Files\Storage\IStorage $storage
		 * @param string $mountpoint
		 * @param array $arguments (optional) configuration for the storage backend
		 * @param \OCP\Files\Storage\IStorageFactory $loader
		 * @param array $mountOptions mount specific options
		 * @param int|null $mountId
		 * @throws \Exception
		 */
		public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
			throw new \Exception('stub');
		}
	
		/**
		 * get complete path to the mount point, relative to data/
		 *
		 * @return string
		 */
		public function getMountPoint() {
			throw new \Exception('stub');
		}
	
		/**
		 * Sets the mount point path, relative to data/
		 *
		 * @param string $mountPoint new mount point
		 */
		public function setMountPoint($mountPoint) {
			throw new \Exception('stub');
		}
	
		/**
		 * @return \OCP\Files\Storage\IStorage
		 */
		public function getStorage() {
			throw new \Exception('stub');
		}
	
		/**
		 * @return string
		 */
		public function getStorageId() {
			throw new \Exception('stub');
		}
	
		/**
		 * @return int
		 */
		public function getNumericStorageId() {
			throw new \Exception('stub');
		}
	
		/**
		 * @param string $path
		 * @return string
		 */
		public function getInternalPath($path) {
			throw new \Exception('stub');
		}
	
		/**
		 * @param callable $wrapper
		 */
		public function wrapStorage($wrapper) {
			throw new \Exception('stub');
		}
	
		/**
		 * Get a mount option
		 *
		 * @param string $name Name of the mount option to get
		 * @param mixed $default Default value for the mount option
		 * @return mixed
		 */
		public function getOption($name, $default) {
			throw new \Exception('stub');
		}
	
		/**
		 * Get all options for the mount
		 *
		 * @return array
		 */
		public function getOptions() {
			throw new \Exception('stub');
		}
	
		/**
		 * @return int
		 */
		public function getStorageRootId() {
			throw new \Exception('stub');
		}
	
		public function getMountId() {
			throw new \Exception('stub');
		}
	
		public function getMountType() {
			throw new \Exception('stub');
		}

		public function getMountProvider(): string {
			throw new \Exception('stub');
		}
	}
}

namespace OC\Files\Storage\Wrapper{

	use OCP\Files\Cache\ICache;
	use OCP\Files\Cache\ICacheEntry;
	use OCP\Files\Search\ISearchQuery;
	use OCP\Files\Storage\IStorage;

	class Wrapper implements IStorage {
		public function __construct(array $parameters) {
		}

		public function getWrapperStorage(): ?IStorage {}

		public function getId() {}

		public function mkdir($path) {}

		public function rmdir($path) {}

		public function opendir($path) {
			throw new \Exception('stub');
		}

		public function is_dir($path) {
			throw new \Exception('stub');
		}

		public function is_file($path) {
			throw new \Exception('stub');
		}

		public function stat($path) {
			throw new \Exception('stub');
		}

		public function filetype($path) {
			throw new \Exception('stub');
		}

		public function filesize($path) {
			throw new \Exception('stub');
		}

		public function isCreatable($path) {
			throw new \Exception('stub');
		}

		public function isReadable($path) {
			throw new \Exception('stub');
		}

		public function isUpdatable($path) {
			throw new \Exception('stub');
		}

		public function isDeletable($path) {
			throw new \Exception('stub');
		}

		public function isSharable($path) {
			throw new \Exception('stub');
		}

		public function getPermissions($path) {
			throw new \Exception('stub');
		}

		public function file_exists($path) {
			throw new \Exception('stub');
		}

		public function filemtime($path) {
			throw new \Exception('stub');
		}

		public function file_get_contents($path) {
			throw new \Exception('stub');
		}

		public function file_put_contents($path, $data) {
			throw new \Exception('stub');
		}

		public function unlink($path) {
			throw new \Exception('stub');
		}

		public function rename($path1, $path2) {
			throw new \Exception('stub');
		}

		public function copy($path1, $path2) {
			throw new \Exception('stub');
		}

		public function fopen($path, $mode) {
			throw new \Exception('stub');
		}

		public function getMimeType($path) {
			throw new \Exception('stub');
		}

		public function hash($type, $path, $raw = false) {
			throw new \Exception('stub');
		}

		public function free_space($path) {
			throw new \Exception('stub');
		}

		public function touch($path, $mtime = null) {
			throw new \Exception('stub');
		}

		public function getLocalFile($path) {
			throw new \Exception('stub');
		}

		public function hasUpdated($path, $time) {
			throw new \Exception('stub');
		}

		public function getETag($path) {
			throw new \Exception('stub');
		}

		public function isLocal() {
			throw new \Exception('stub');
		}

		public function instanceOfStorage($class) {
			throw new \Exception('stub');
		}

		public function getDirectDownload($path) {
			throw new \Exception('stub');
		}

		public function verifyPath($path, $fileName) {
			throw new \Exception('stub');
		}

		public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
			throw new \Exception('stub');
		}

		public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
			throw new \Exception('stub');
		}

		public function test() {
			throw new \Exception('stub');
		}

		public function getAvailability() {
			throw new \Exception('stub');
		}

		public function setAvailability($isAvailable) {
			throw new \Exception('stub');
		}

		public function getOwner($path) {
			throw new \Exception('stub');
		}

		public function getCache() {
			throw new \Exception('stub');
		}

		public function getPropagator() {
			throw new \Exception('stub');
		}

		public function getScanner() {
			throw new \Exception('stub');
		}

		public function getUpdater() {
			throw new \Exception('stub');
		}

		public function getWatcher() {
			throw new \Exception('stub');
		}
	}

	class Jail extends Wrapper {
		public function getUnjailedPath(string $path): string {}
	}

	class Quota extends Wrapper {
		public function getQuota() {}
	}

	class PermissionsMask extends Wrapper {
		public function getQuota() {}
	}
}
