mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
refactor: Apply rector refactorings
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
953d1ab962
commit
78a175fc74
16 changed files with 35 additions and 35 deletions
|
|
@ -25,12 +25,6 @@ use function array_values;
|
|||
|
||||
abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||
|
||||
/** @var ProxyMapper */
|
||||
private $proxyMapper;
|
||||
|
||||
/** @var string */
|
||||
private $principalPrefix;
|
||||
|
||||
/** @var string */
|
||||
private $dbTableName;
|
||||
|
||||
|
|
@ -45,13 +39,11 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
private IUserSession $userSession,
|
||||
private IGroupManager $groupManager,
|
||||
private LoggerInterface $logger,
|
||||
ProxyMapper $proxyMapper,
|
||||
string $principalPrefix,
|
||||
private ProxyMapper $proxyMapper,
|
||||
private string $principalPrefix,
|
||||
string $dbPrefix,
|
||||
private string $cuType,
|
||||
) {
|
||||
$this->proxyMapper = $proxyMapper;
|
||||
$this->principalPrefix = $principalPrefix;
|
||||
$this->dbTableName = 'calendar_' . $dbPrefix . 's';
|
||||
$this->dbMetaDataTableName = $this->dbTableName . '_md';
|
||||
$this->dbForeignKeyName = $dbPrefix . '_id';
|
||||
|
|
|
|||
|
|
@ -41,9 +41,6 @@ class Principal implements BackendInterface {
|
|||
/** @var bool */
|
||||
private $hasCircles;
|
||||
|
||||
/** @var ProxyMapper */
|
||||
private $proxyMapper;
|
||||
|
||||
/** @var KnownUserService */
|
||||
private $knownUserService;
|
||||
|
||||
|
|
@ -54,7 +51,7 @@ class Principal implements BackendInterface {
|
|||
private IShareManager $shareManager,
|
||||
private IUserSession $userSession,
|
||||
private IAppManager $appManager,
|
||||
ProxyMapper $proxyMapper,
|
||||
private ProxyMapper $proxyMapper,
|
||||
KnownUserService $knownUserService,
|
||||
private IConfig $config,
|
||||
private IFactory $languageFactory,
|
||||
|
|
@ -62,7 +59,6 @@ class Principal implements BackendInterface {
|
|||
) {
|
||||
$this->principalPrefix = trim($principalPrefix, '/');
|
||||
$this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/');
|
||||
$this->proxyMapper = $proxyMapper;
|
||||
$this->knownUserService = $knownUserService;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OCA\DAV\CalDAV\Proxy\ProxyMapper;
|
|||
use OCA\DAV\DAV\CustomPropertiesBackend;
|
||||
use OCA\DAV\DAV\ViewOnlyPlugin;
|
||||
use OCA\DAV\Files\BrowserErrorPagePlugin;
|
||||
use OCA\DAV\Files\Sharing\RootCollection;
|
||||
use OCA\DAV\Upload\CleanupService;
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCP\Accounts\IAccountManager;
|
||||
|
|
@ -150,7 +151,7 @@ class ServerFactory {
|
|||
);
|
||||
|
||||
// Mount the share collection at /public.php/dav/shares/<share token>
|
||||
$rootCollection->addChild(new \OCA\DAV\Files\Sharing\RootCollection(
|
||||
$rootCollection->addChild(new RootCollection(
|
||||
$root,
|
||||
$userPrincipalBackend,
|
||||
'principals/shares',
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OCA\DAV\Events;
|
||||
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
|
|
@ -16,7 +17,7 @@ use OCP\EventDispatcher\Event;
|
|||
* @package OCA\DAV\Events
|
||||
* @since 20.0.0
|
||||
*
|
||||
* @psalm-import-type CalendarInfo from \OCA\DAV\CalDAV\CalDavBackend
|
||||
* @psalm-import-type CalendarInfo from CalDavBackend
|
||||
*/
|
||||
class CalendarShareUpdatedEvent extends Event {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
script('dav', 'settings-example-content');
|
||||
\OCP\Util::addScript('dav', 'settings-example-content', 'core');
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\DAV\Tests\integration\DAV\Sharing;
|
||||
|
||||
use OC\Memcache\NullCache;
|
||||
use OCA\DAV\CalDAV\Calendar;
|
||||
use OCA\DAV\CalDAV\Sharing\Service;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\Sharing\Backend;
|
||||
use OCA\DAV\DAV\Sharing\SharingMapper;
|
||||
|
|
@ -50,11 +52,11 @@ class CalDavSharingBackendTest extends TestCase {
|
|||
$this->principalBackend = $this->createMock(Principal::class);
|
||||
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||
$this->cacheFactory->method('createInMemory')
|
||||
->willReturn(new \OC\Memcache\NullCache());
|
||||
->willReturn(new NullCache());
|
||||
$this->logger = new \Psr\Log\NullLogger();
|
||||
|
||||
$this->sharingMapper = new SharingMapper($this->db);
|
||||
$this->sharingService = new \OCA\DAV\CalDAV\Sharing\Service($this->sharingMapper);
|
||||
$this->sharingService = new Service($this->sharingMapper);
|
||||
|
||||
$this->sharingBackend = new \OCA\DAV\CalDAV\Sharing\Backend(
|
||||
$this->userManager,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OC\Files\View;
|
|||
use OCA\DAV\Connector\Sabre\Directory;
|
||||
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
|
||||
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
||||
use OCA\Files_Sharing\External\Storage;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\InvalidPathException;
|
||||
|
|
@ -286,7 +287,7 @@ class DirectoryTest extends \Test\TestCase {
|
|||
->willReturnMap([
|
||||
['\OCA\Files_Sharing\SharedStorage', false],
|
||||
['\OC\Files\Storage\Wrapper\Quota', false],
|
||||
[\OCA\Files_Sharing\External\Storage::class, false],
|
||||
[Storage::class, false],
|
||||
]);
|
||||
|
||||
$storage->expects($this->once())
|
||||
|
|
@ -342,7 +343,7 @@ class DirectoryTest extends \Test\TestCase {
|
|||
->willReturnMap([
|
||||
['\OCA\Files_Sharing\SharedStorage', false],
|
||||
['\OC\Files\Storage\Wrapper\Quota', true],
|
||||
[\OCA\Files_Sharing\External\Storage::class, false],
|
||||
[Storage::class, false],
|
||||
]);
|
||||
|
||||
$storage->expects($this->once())
|
||||
|
|
|
|||
3
apps/files_sharing/lib/External/Scanner.php
vendored
3
apps/files_sharing/lib/External/Scanner.php
vendored
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
namespace OCA\Files_Sharing\External;
|
||||
|
||||
use OC\Files\Cache\CacheEntry;
|
||||
use OC\ForbiddenException;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\StorageInvalidException;
|
||||
|
|
@ -29,7 +30,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
|
|||
* @param string $file file to scan
|
||||
* @param int $reuseExisting
|
||||
* @param int $parentId
|
||||
* @param \OC\Files\Cache\CacheEntry|array|null|false $cacheData existing data in the cache for the file to be scanned
|
||||
* @param CacheEntry|array|null|false $cacheData existing data in the cache for the file to be scanned
|
||||
* @param bool $lock set to false to disable getting an additional read lock during scanning
|
||||
* @param array|null $data the metadata for the file, as returned by the storage
|
||||
* @return array|null an array of metadata of the scanned file
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use OCP\Files\IRootFolder;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\IUserBackend;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Util;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\InvalidOptionException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
|
@ -96,7 +97,7 @@ class CleanUp extends Command {
|
|||
$node = $this->rootFolder->get($path);
|
||||
|
||||
if ($verbose) {
|
||||
$output->writeln('Deleting <info>' . \OCP\Util::humanFileSize($node->getSize()) . "</info> in trash for <info>$uid</info>.");
|
||||
$output->writeln('Deleting <info>' . Util::humanFileSize($node->getSize()) . "</info> in trash for <info>$uid</info>.");
|
||||
}
|
||||
$node->delete();
|
||||
if ($this->rootFolder->nodeExists($path)) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use OCP\Command\IBus;
|
|||
use OCP\IConfig;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Util;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
|
@ -45,7 +46,7 @@ class Size extends Base {
|
|||
$size = $input->getArgument('size');
|
||||
|
||||
if ($size) {
|
||||
$parsedSize = \OCP\Util::computerFileSize($size);
|
||||
$parsedSize = Util::computerFileSize($size);
|
||||
if ($parsedSize === false) {
|
||||
$output->writeln('<error>Failed to parse input size</error>');
|
||||
return -1;
|
||||
|
|
@ -70,7 +71,7 @@ class Size extends Base {
|
|||
if ($globalSize < 0) {
|
||||
$globalHumanSize = 'default (50% of available space)';
|
||||
} else {
|
||||
$globalHumanSize = \OCP\Util::humanFileSize($globalSize);
|
||||
$globalHumanSize = Util::humanFileSize($globalSize);
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
|
|
@ -79,7 +80,7 @@ class Size extends Base {
|
|||
if ($userSize < 0) {
|
||||
$userHumanSize = ($globalSize < 0) ? $globalHumanSize : "default($globalHumanSize)";
|
||||
} else {
|
||||
$userHumanSize = \OCP\Util::humanFileSize($userSize);
|
||||
$userHumanSize = Util::humanFileSize($userSize);
|
||||
}
|
||||
|
||||
if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
|
||||
|
|
@ -106,7 +107,7 @@ class Size extends Base {
|
|||
if (count($userValues)) {
|
||||
$output->writeln('Per-user sizes:');
|
||||
$this->writeArrayInOutputFormat($input, $output, array_map(function ($size) {
|
||||
return \OCP\Util::humanFileSize($size);
|
||||
return Util::humanFileSize($size);
|
||||
}, $userValues));
|
||||
} else {
|
||||
$output->writeln('No per-user sizes configured');
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OC\Files\Filesystem;
|
|||
use OC\Files\Storage\Local;
|
||||
use OC\Files\View;
|
||||
use OC\SystemConfig;
|
||||
use OC\User\Database;
|
||||
use OCA\Files_Sharing\AppInfo\Application;
|
||||
use OCA\Files_Trashbin\AppInfo\Application as TrashbinApplication;
|
||||
use OCA\Files_Trashbin\Expiration;
|
||||
|
|
@ -59,7 +60,7 @@ class TrashbinTest extends \Test\TestCase {
|
|||
|
||||
// reset backend
|
||||
Server::get(IUserManager::class)->clearBackends();
|
||||
Server::get(IUserManager::class)->registerBackend(new \OC\User\Database());
|
||||
Server::get(IUserManager::class)->registerBackend(new Database());
|
||||
|
||||
// clear share hooks
|
||||
\OC_Hook::clear('OCP\\Share');
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ use OCP\Files\Folder;
|
|||
use OCP\Files\IMimeTypeLoader;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\Node;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
|
@ -378,7 +379,7 @@ class FileEventsListener implements IEventListener {
|
|||
|
||||
try {
|
||||
$owner = $node->getOwner()?->getUid();
|
||||
} catch (\OCP\Files\NotFoundException) {
|
||||
} catch (NotFoundException) {
|
||||
$owner = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ class VersioningTest extends \Test\TestCase {
|
|||
|
||||
$eventDispatcher = Server::get(IEventDispatcher::class);
|
||||
$eventFired = false;
|
||||
$eventDispatcher->addListener(VersionRestoredEvent::class, function ($event) use (&$eventFired, $t2) {
|
||||
$eventDispatcher->addListener(VersionRestoredEvent::class, function ($event) use (&$eventFired, $t2): void {
|
||||
$eventFired = true;
|
||||
$this->assertEquals('/sub/test.txt', $event->getVersion()->getVersionPath());
|
||||
$this->assertTrue($event->getVersion()->getRevisionId() > 0);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
use OCP\IBinaryFinder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Server;
|
||||
use OCP\Settings\IDelegatedSettings;
|
||||
|
||||
class Mail implements IDelegatedSettings {
|
||||
|
|
@ -26,7 +27,7 @@ class Mail implements IDelegatedSettings {
|
|||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
$finder = \OCP\Server::get(IBinaryFinder::class);
|
||||
$finder = Server::get(IBinaryFinder::class);
|
||||
|
||||
$parameters = [
|
||||
// Mail
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Notification\IManager;
|
||||
use OCP\Server;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\Util;
|
||||
|
||||
class PersonalInfo implements ISettings {
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ class PersonalInfo implements ISettings {
|
|||
if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
|
||||
$totalSpace = $this->l->t('Unlimited');
|
||||
} else {
|
||||
$totalSpace = \OCP\Util::humanFileSize($storageInfo['total']);
|
||||
$totalSpace = Util::humanFileSize($storageInfo['total']);
|
||||
}
|
||||
|
||||
$messageParameters = $this->getMessageParameters($account);
|
||||
|
|
@ -88,7 +89,7 @@ class PersonalInfo implements ISettings {
|
|||
'groups' => $this->getGroups($user),
|
||||
'quota' => $storageInfo['quota'],
|
||||
'totalSpace' => $totalSpace,
|
||||
'usage' => \OCP\Util::humanFileSize($storageInfo['used']),
|
||||
'usage' => Util::humanFileSize($storageInfo['used']),
|
||||
'usageRelative' => round($storageInfo['relative']),
|
||||
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
|
||||
'emailMap' => $this->getEmailMap($account),
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ class User {
|
|||
}
|
||||
|
||||
private function verifyQuotaValue(string $quotaValue): bool {
|
||||
return $quotaValue === 'none' || $quotaValue === 'default' || \OCP\Util::computerFileSize($quotaValue) !== false;
|
||||
return $quotaValue === 'none' || $quotaValue === 'default' || Util::computerFileSize($quotaValue) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue