Skip to content

Commit

Permalink
Merge pull request #3239 from nextcloud/fix/psalm/update-stubs
Browse files Browse the repository at this point in the history
fix(psalm): Update stubs
  • Loading branch information
come-nc authored Sep 17, 2024
2 parents 91db1ef + e274b8b commit 017b6a4
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 235 deletions.
5 changes: 1 addition & 4 deletions lib/Mount/GroupFolderStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public function getFolderId(): int {
return $this->folderId;
}

/**
* @psalm-suppress FalsableReturnStatement Return type of getOwner is not clear even in server
*/
public function getOwner($path) {
public function getOwner($path): string|false {
$user = $this->userSession->getUser();
if ($user !== null) {
return $user->getUID();
Expand Down
1 change: 1 addition & 0 deletions tests/stubs/oc_files_cache_scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\Files\Cache\IScanner;
use OCP\Files\ForbiddenException;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
Expand Down
4 changes: 0 additions & 4 deletions tests/stubs/oc_files_objectstore_objectstorestorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public function mkdir($path, bool $force = false)
/**
* Object Stores use a NoopScanner because metadata is directly stored in
* the file cache and cannot really scan the filesystem. The storage passed in is not used anywhere.
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
* @return \OC\Files\ObjectStore\ObjectStoreScanner
*/
public function getScanner($path = '', $storage = null)
{
Expand Down
60 changes: 16 additions & 44 deletions tests/stubs/oc_files_storage_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
use LocalTempFileTrait;

protected $cache;
protected $scanner;
protected $watcher;
protected $propagator;
protected ?Cache $cache = null;
protected ?Scanner $scanner = null;
protected ?Watcher $watcher = null;
protected ?Propagator $propagator = null;
protected $storageCache;
protected $updater;
protected ?Updater $updater = null;

protected $mountOptions = [];
protected array $mountOptions = [];
protected $owner = null;

public function __construct($parameters) {
Expand Down Expand Up @@ -129,10 +129,6 @@ public function getMimeType($path)

public function hash($type, $path, $raw = false)
{
}

public function search($query)
{
}

public function getLocalFile($path)
Expand Down Expand Up @@ -168,6 +164,9 @@ protected function getCacheDependencies(): CacheDependencies
{
}

/**
* @return Cache
*/
public function getCache($path = '', $storage = null)
{
}
Expand All @@ -180,16 +179,16 @@ public function getWatcher($path = '', $storage = null)
{
}

/**
* get a propagator instance for the cache
*
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Propagator
*/
public function getPropagator($storage = null)
{
}

/**
* get a propagator instance for the cache
*
* @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher
* @return Updater
*/
public function getUpdater($storage = null)
{
}
Expand All @@ -198,13 +197,7 @@ public function getStorageCache($storage = null)
{
}

/**
* get the owner of a path
*
* @param string $path The path to get the owner
* @return string|false uid or false
*/
public function getOwner($path)
public function getOwner($path): string|false
{
}

Expand Down Expand Up @@ -330,39 +323,18 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
{
}

/**
* @inheritdoc
*/
public function getMetaData($path)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function releaseLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function changeLock($path, $type, ILockingProvider $provider)
{
}
Expand Down
85 changes: 19 additions & 66 deletions tests/stubs/oc_files_storage_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,58 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OC\Files\Storage;

use OCP\Lock\ILockingProvider;
use OC\Files\Cache\Cache;
use OC\Files\Cache\Propagator;
use OC\Files\Cache\Scanner;
use OC\Files\Cache\Updater;
use OC\Files\Cache\Watcher;
use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IStorage;

/**
* Provide a common interface to all different storage options
*
* All paths passed to the storage are relative to the storage and should NOT have a leading slash.
*/
interface Storage extends \OCP\Files\Storage {
interface Storage extends IStorage, ILockingStorage {
/**
* get a cache instance for the storage
*
* @param string $path
* @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
* @inheritDoc
* @return Cache
*/
public function getCache($path = '', $storage = null)
{
}

/**
* get a scanner instance for the storage
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
* @return \OC\Files\Cache\Scanner
* @inheritDoc
* @return Scanner
*/
public function getScanner($path = '', $storage = null)
{
}


/**
* get the user id of the owner of a file or folder
*
* @param string $path
* @return string
*/
public function getOwner($path)
{
}

/**
* get a watcher instance for the cache
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Watcher
* @inheritDoc
* @return Watcher
*/
public function getWatcher($path = '', $storage = null)
{
}

/**
* get a propagator instance for the cache
*
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Propagator
* @inheritDoc
* @return Propagator
*/
public function getPropagator($storage = null)
{
}

/**
* get a updater instance for the cache
*
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Updater
* @inheritDoc
* @return Updater
*/
public function getUpdater($storage = null)
{
Expand All @@ -92,36 +75,6 @@ public function getStorageCache()
*/
public function getMetaData($path)
{
}

/**
* @param string $path The path of the file to acquire the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path The path of the file to release the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function releaseLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path The path of the file to change the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function changeLock($path, $type, ILockingProvider $provider)
{
}

/**
Expand Down
48 changes: 1 addition & 47 deletions tests/stubs/oc_files_storage_wrapper_jail.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,6 @@ public function hash($type, $path, $raw = false)
*/
public function free_space($path)
{
}

/**
* search for occurrences of $query in file names
*
* @param string $query
* @return array|bool
*/
public function search($query)
{
}

/**
Expand Down Expand Up @@ -360,34 +350,14 @@ public function hasUpdated($path, $time)
{
}

/**
* get a cache instance for the storage
*
* @param string $path
* @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
*/
public function getCache($path = '', $storage = null)
{
}

/**
* get the user id of the owner of a file or folder
*
* @param string $path
* @return string
*/
public function getOwner($path)
public function getOwner($path): string|false
{
}

/**
* get a watcher instance for the cache
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Watcher
*/
public function getWatcher($path = '', $storage = null)
{
}
Expand All @@ -406,30 +376,14 @@ public function getMetaData($path)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, ILockingProvider $provider)
{
}

/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
*/
public function changeLock($path, $type, ILockingProvider $provider)
{
}
Expand Down
7 changes: 0 additions & 7 deletions tests/stubs/oc_files_storage_wrapper_permissionsmask.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ public function fopen($path, $mode)
{
}

/**
* get a cache instance for the storage
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
*/
public function getCache($path = '', $storage = null)
{
}
Expand Down
Loading

0 comments on commit 017b6a4

Please sign in to comment.