Use stub implementation

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
Carl Schwan 2022-08-23 15:00:38 +02:00
parent 07a960d420
commit 33462ff40c
No known key found for this signature in database
GPG Key ID: C3AA6B3A5EFA7AC5
54 changed files with 955 additions and 759 deletions

View File

@ -9,6 +9,7 @@ use Nextcloud\CodingStandard\Config;
$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')

View File

@ -15,7 +15,7 @@
"psalm:update-baseline": "psalm --update-baseline"
},
"require-dev": {
"nextcloud/coding-standard": "^0.5.0",
"nextcloud/coding-standard": "1.0",
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4.22",
"christophwurst/nextcloud": "dev-master",

957
composer.lock generated

File diff suppressed because it is too large Load Diff

BIN
js/photos-main.js Normal file

Binary file not shown.

Binary file not shown.

BIN
js/photos-main.js.map Normal file

Binary file not shown.

BIN
js/photos-service-worker.js Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace OCA\Photos\Migration;
use Closure;
use Doctrine\DBAL\Types\Types;
use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

View File

@ -78,10 +78,10 @@ class PropFindPlugin extends ServerPlugin {
public function propFind(PropFind $propFind, INode $node): void {
if ($node instanceof AlbumPhoto) {
$propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, fn () => $node->getFile()->getFileId());
$propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, fn () => $node->getETag());
$propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName());
$propFind->handle(self::REALPATH_PROPERTYNAME, fn () => $node->getFileInfo()->getPath());
$propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0);
$propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, fn () => $node->getETag());
$propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName());
$propFind->handle(self::REALPATH_PROPERTYNAME, fn () => $node->getFileInfo()->getPath());
$propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0);
$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
@ -106,8 +106,8 @@ class PropFindPlugin extends ServerPlugin {
if ($node instanceof AlbumRoot) {
$propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLastAddedPhoto());
$propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren()));
$propFind->handle(self::LOCATION_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLocation());
$propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren()));
$propFind->handle(self::LOCATION_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLocation());
$propFind->handle(self::DATE_RANGE_PROPERTYNAME, fn () => json_encode($node->getDateRange()));
// TODO detect dynamically which metadata groups are requested and

View File

@ -1,18 +1,30 @@
<?xml version="1.0"?>
<psalm errorLevel="4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="tests/psalm-baseline.xml">
<psalm
errorLevel="4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="tests/psalm-baseline.xml"
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
</stubs>
<projectFiles>
<directory name="lib" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<extraFiles>
<directory name="vendor" />
<ignoreFiles>
<directory name="vendor/phpunit/php-code-coverage" />
</ignoreFiles>
</extraFiles>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC" />
<referencedClass name="Doctrine\DBAL\Types\Type" />
<referencedClass name="OC\Metadata\IMetadataManager" />
<referencedClass name="OC\Metadata\FileMetadata" />
<referencedClass name="OCA\DAV\Connector\Sabre\Principal" />
<referencedClass name="OCA\DAV\Connector\Sabre\File" />
<referencedClass name="OCA\DAV\Connector\Sabre\FilesPlugin" />
@ -25,23 +37,7 @@
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="Doctrine\DBAL\Schema\Table" />
<referencedClass name="Doctrine\DBAL\Statement" />
<referencedClass name="OC\Metadata\IMetadataManager" />
<referencedClass name="OC\Metadata\FileMetadata" />
</errorLevel>
</UndefinedDocblockClass>
<MissingDependency>
<errorLevel type="suppress">
<!-- <file name="OC\Hooks\Emitter" /> -->
</errorLevel>
</MissingDependency>
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<!-- <referencedMethod name="/getId/" /> -->
<referencedMethod name="/INode::*/" />
<referencedMethod name="/Sabre\\DAV\\INode::*/" />
<referencedMethod name="/OCA\\DAV\\Connector\\Sabre\\File::*/" />
<!-- <referencedMethod name="/\(Sabre\\DAV\\INode\&OCA\\DAV\\Connector\\Sabre\\File\)::getFileInfo/" /> -->
</errorLevel>
</UndefinedInterfaceMethod>
</issueHandlers>
</psalm>

View File

@ -153,7 +153,7 @@ class AlbumMapperTest extends TestCase {
public function testCreateRenameGet() {
$album = $this->mapper->create("user1", "album1");
$this->mapper->rename($album->getId(),"renamed");
$this->mapper->rename($album->getId(), "renamed");
$retrievedAlbum = $this->mapper->get($album->getId());
$this->assertEquals("renamed", $retrievedAlbum->getTitle());
@ -161,7 +161,7 @@ class AlbumMapperTest extends TestCase {
public function testCreateUpdateGet() {
$album = $this->mapper->create("user1", "album1");
$this->mapper->setLocation($album->getId(),"nowhere");
$this->mapper->setLocation($album->getId(), "nowhere");
$retrievedAlbum = $this->mapper->get($album->getId());
$this->assertEquals("nowhere", $retrievedAlbum->getLocation());

View File

@ -1,22 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<files psalm-version="4.26.0@6998fabb2bf528b65777bf9941920888d23c03ac">
<file src="lib/Controller/AlbumsController.php">
<MissingDependency occurrences="4">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="2">
<code>SharedStorage</code>
<code>\OCA\GroupFolders\Mount\GroupFolderStorage</code>
</UndefinedClass>
</file>
<file src="lib/Controller/PageController.php">
<MissingDependency occurrences="3">
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="10">
<code>$e</code>
<code>LoadSidebar</code>

688
tests/stub.phpstub Normal file
View File

@ -0,0 +1,688 @@
<?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 {
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() {}
}
}
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;
}
}
namespace Symfony\Component\Console\Question {
class ConfirmationQuestion {
public function __construct(string $text, bool $default) {}
}
}
namespace Symfony\Component\Console\Output {
class OutputInterface {
public const VERBOSITY_VERBOSE = 1;
public function writeln(string $text, int $flat = 0) {}
}
}
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() {}
}
}
namespace OC\Metadata {
use OCP\Files\File;
/**
* Interface to manage additional metadata for files
*/
interface IMetadataManager {
/**
* @param class-string<IMetadataProvider> $className
*/
public function registerProvider(string $className): void;
/**
* Generate the metadata for one file
*/
public function generateMetadata(File $node, bool $checkExisting = false): void;
/**
* Clear the metadata for one file
*/
public function clearMetadata(int $fileId): void;
/** @return array<int, FileMetadata> */
public function fetchMetadataFor(string $group, array $fileIds): array;
/**
* Get the capabilites as an array of mimetype regex to the type provided
*/
public function getCapabilities(): array;
}
/**
* Interface for the metadata providers. If you want an application to provide
* some metadata, you can use this to store them.
*/
interface IMetadataProvider {
/**
* The list of groups that this metadata provider is able to provide.
*
* @return string[]
*/
public static function groupsProvided(): array;
/**
* Check if the metadata provider is available. A metadata provider might be
* unavailable due to a php extension not being installed.
*/
public static function isAvailable(): bool;
/**
* Get the mimetypes supported as a regex.
*/
public static function getMimetypesSupported(): string;
/**
* Execute the extraction on the specified file. The metadata should be
* grouped by metadata
*
* Each group should be json serializable and the string representation
* shouldn't be longer than 4000 characters.
*
* @param File $file The file to extract the metadata from
* @param array<string, FileMetadata> An array containing all the metadata fetched.
*/
public function execute(File $file): array;
}
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;
/**
* @method string getGroupName()
* @method void setGroupName(string $groupName)
* @method string getMetadata()
* @method void setMetadata(array $metadata)
* @see \OC\Core\Migrations\Version240000Date20220404230027
*/
class FileMetadata extends Entity {
}
}
namespace OCA\DAV\Connector\Sabre {
class Node extends \Sabre\Dav\INode {
public function getNode(): \OCP\Files\Node { }
public function getId(): int {}
}
class File extends Node {}
class Directory extends Node {}
}
namespace OCA\DAV\Connector\Sabre\Exception {
class FileLocked extends \Exception {}
class Forbidden extends \Exception {}
}
namespace OCA\DAV\Upload {
class FutureFile extends \Sabre\Dav\INode {}
}
namespace Doctrine\DBAL\Exception {
class UniqueConstraintViolationException extends \Exception {}
}