refactor: Run rector

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
pull/56494/head
Carl Schwan 2025-11-17 11:58:02 +07:00
parent 3682dbbf5e
commit 503a65ddd0
15 changed files with 39 additions and 30 deletions

@ -17,6 +17,7 @@ use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\User\IAvailabilityCoordinator;
use OCP\Util;
use Psr\Log\LoggerInterface;
class AvailabilitySettings implements ISettings {
@ -56,8 +57,8 @@ class AvailabilitySettings implements ISettings {
}
}
\OCP\Util::addStyle(Application::APP_ID, 'settings-personal-availability');
\OCP\Util::addScript(Application::APP_ID, 'settings-personal-availability');
Util::addStyle(Application::APP_ID, 'settings-personal-availability');
Util::addScript(Application::APP_ID, 'settings-personal-availability');
return new TemplateResponse(Application::APP_ID, 'settings-personal-availability');
}

@ -13,6 +13,7 @@ use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
use OCP\Util;
class CalDAVSettings implements IDelegatedSettings {
@ -45,8 +46,8 @@ class CalDAVSettings implements IDelegatedSettings {
$this->initialState->provideInitialState($key, $value === 'yes');
}
\OCP\Util::addScript(Application::APP_ID, 'settings-admin-caldav');
\OCP\Util::addStyle(Application::APP_ID, 'settings-admin-caldav');
Util::addScript(Application::APP_ID, 'settings-admin-caldav');
Util::addStyle(Application::APP_ID, 'settings-admin-caldav');
return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
}

@ -16,6 +16,7 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\Settings\ISettings;
use OCP\Util;
class ExampleContentSettings implements ISettings {
public function __construct(
@ -53,8 +54,8 @@ class ExampleContentSettings implements ISettings {
);
}
\OCP\Util::addStyle(Application::APP_ID, 'settings-admin-example-content');
\OCP\Util::addScript(Application::APP_ID, 'settings-admin-example-content');
Util::addStyle(Application::APP_ID, 'settings-admin-example-content');
Util::addScript(Application::APP_ID, 'settings-admin-example-content');
return new TemplateResponse(Application::APP_ID, 'settings-admin-example-content');
}

@ -134,7 +134,7 @@ class PaginatePluginTest extends TestCase {
private function expectSequentialCalls(MockObject $mock, string $method, array $expectedCalls): void {
$mock->expects(self::exactly(\count($expectedCalls)))
->method($method)
->willReturnCallback(function (...$args) use (&$expectedCalls) {
->willReturnCallback(function (...$args) use (&$expectedCalls): void {
$expected = array_shift($expectedCalls);
self::assertNotNull($expected);
self::assertSame($expected, $args);

@ -5529,8 +5529,8 @@ class ShareAPIControllerTest extends TestCase {
$owner = $this->createMock(IUser::class);
$storage = $this->createMock(SharedStorage::class);
$originalShare = $this->createMock(IShare::class);
$attributes = $this->createMock(\OCP\Share\IAttributes::class);
$shareAttributes = $this->createMock(\OCP\Share\IAttributes::class);
$attributes = $this->createMock(IShareAttributes::class);
$shareAttributes = $this->createMock(IShareAttributes::class);
$share->method('getSharedBy')->willReturn('sharedByUser');
$share->method('getNodeId')->willReturn(42);
@ -5565,7 +5565,7 @@ class ShareAPIControllerTest extends TestCase {
$node = $this->createMock(File::class);
$userFolder = $this->createMock(Folder::class);
$owner = $this->createMock(IUser::class);
$storage = $this->createMock(\OCA\Files_Sharing\External\Storage::class);
$storage = $this->createMock(Storage::class);
$share->method('getSharedBy')->willReturn('sharedByUser');
$share->method('getNodeId')->willReturn(42);
@ -5575,7 +5575,7 @@ class ShareAPIControllerTest extends TestCase {
$node->method('getStorage')->willReturn($storage);
$storage->method('instanceOfStorage')->willReturnMap([
[SharedStorage::class, false],
[\OCA\Files_Sharing\External\Storage::class, true]
[Storage::class, true]
]);
$userFolder->method('getById')->with(42)->willReturn([$node]);

@ -11,6 +11,7 @@ namespace OCA\Settings\Tests\Command\AdminDelegation;
use OC\Settings\AuthorizedGroup;
use OCA\Settings\Command\AdminDelegation\Add;
use OCA\Settings\Service\AuthorizedGroupService;
use OCA\Settings\Settings\Admin\Server;
use OCP\IGroupManager;
use OCP\Settings\IManager;
use PHPUnit\Framework\MockObject\MockObject;
@ -45,7 +46,7 @@ class AddTest extends TestCase {
}
public function testExecuteSuccessfulDelegation(): void {
$settingClass = \OCA\Settings\Settings\Admin\Server::class;
$settingClass = Server::class;
$groupId = 'testgroup';
// Mock valid delegated settings class
@ -93,7 +94,7 @@ class AddTest extends TestCase {
}
public function testExecuteNonExistentGroup(): void {
$settingClass = \OCA\Settings\Settings\Admin\Server::class;
$settingClass = Server::class;
$groupId = 'nonexistentgroup';
$this->input->expects($this->exactly(2))

@ -10,6 +10,7 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IL10N;
use OCP\Settings\IDelegatedSettings;
use OCP\Util;
class Admin implements IDelegatedSettings {
public function __construct(
@ -26,8 +27,8 @@ class Admin implements IDelegatedSettings {
$this->initialState->provideInitialState('sendPasswordMail', $this->settingsManager->sendPasswordByMail());
$this->initialState->provideInitialState('replyToInitiator', $this->settingsManager->replyToInitiator());
\OCP\Util::addStyle('sharebymail', 'admin-settings');
\OCP\Util::addScript('sharebymail', 'admin-settings');
Util::addStyle('sharebymail', 'admin-settings');
Util::addScript('sharebymail', 'admin-settings');
return new TemplateResponse('sharebymail', 'settings-admin', [], '');
}

@ -14,11 +14,12 @@ use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
use OCP\Server;
use OCP\Template\ITemplate;
use OCP\Template\ITemplateManager;
use OCP\Util;
class Personal implements IPersonalProviderSettings {
public function getBody(): ITemplate {
\OCP\Util::addScript(Application::APP_ID, 'settings-personal');
\OCP\Util::addStyle(Application::APP_ID, 'settings-personal');
Util::addScript(Application::APP_ID, 'settings-personal');
Util::addStyle(Application::APP_ID, 'settings-personal');
return Server::get(ITemplateManager::class)
->getTemplate('twofactor_backupcodes', 'personal');
}

@ -20,7 +20,6 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\Server;
use Psr\Log\LoggerInterface;
/**

@ -19,7 +19,7 @@ use OCP\User\Events\PasswordUpdatedEvent;
*/
class PasswordUpdatedListener implements IEventListener {
public function __construct(
readonly private IVerificationToken $verificationToken,
private readonly IVerificationToken $verificationToken,
) {
}

@ -82,7 +82,7 @@ class AppConfig implements IAppConfig {
private readonly PresetManager $presetManager,
protected LoggerInterface $logger,
protected ICrypto $crypto,
readonly CacheFactory $cacheFactory,
public readonly CacheFactory $cacheFactory,
) {
if ($config->getSystemValueBool('cache_app_config', true) && $cacheFactory->isLocalCacheAvailable()) {
$cacheFactory->withServerVersionPrefix(function (ICacheFactory $factory) {

@ -22,9 +22,9 @@ class BackgroundCleanupJob extends TimedJob {
public function __construct(
ITimeFactory $timeFactory,
readonly private IDBConnection $connection,
readonly private PreviewService $previewService,
readonly private bool $isCLI,
private readonly IDBConnection $connection,
private readonly PreviewService $previewService,
private readonly bool $isCLI,
) {
parent::__construct($timeFactory);
// Run at most once an hour

@ -36,7 +36,7 @@ class ObjectStorePreviewStorage implements IPreviewStorage {
public function __construct(
private readonly PrimaryObjectStoreConfig $objectStoreConfig,
IConfig $config,
readonly private PreviewMapper $previewMapper,
private readonly PreviewMapper $previewMapper,
) {
$this->isMultibucketPreviewDistributionEnabled = $config->getSystemValueBool('objectstore.multibucket.preview-distribution');
}

@ -1021,7 +1021,7 @@ class MailPluginTest extends TestCase {
$this->instantiatePlugin(IShare::TYPE_USER);
/** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
$currentUser = $this->createMock('\OCP\IUser');
$currentUser->expects($this->any())
@ -1043,7 +1043,7 @@ class MailPluginTest extends TestCase {
$this->groupManager->expects($this->any())
->method('getUserGroupIds')
->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) {
->willReturnCallback(function (IUser $user) use ($userToGroupMapping) {
return $userToGroupMapping[$user->getUID()];
});

@ -13,6 +13,7 @@ use OC\AppFramework\Bootstrap\Coordinator;
use OC\AppFramework\Bootstrap\RegistrationContext;
use OC\Files\FilenameValidator;
use OC\Files\Template\TemplateManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\GenericFileException;
use OCP\Files\IRootFolder;
@ -21,6 +22,9 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IPreview;
use OCP\IServerContainer;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use Psr\Log\NullLogger;
use Test\TestCase;
@ -53,14 +57,14 @@ class TemplateManagerTest extends TestCase {
$logger,
);
$serverContainer = $this->createMock(\OCP\IServerContainer::class);
$eventDispatcher = $this->createMock(\OCP\EventDispatcher\IEventDispatcher::class);
$serverContainer = $this->createMock(IServerContainer::class);
$eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->bootstrapCoordinator = $this->createMock(Coordinator::class);
$this->bootstrapCoordinator->method('getRegistrationContext')
->willReturn(new RegistrationContext($logger));
$this->rootFolder = $this->createMock(IRootFolder::class);
$userSession = $this->createMock(\OCP\IUserSession::class);
$userManager = $this->createMock(\OCP\IUserManager::class);
$userSession = $this->createMock(IUserSession::class);
$userManager = $this->createMock(IUserManager::class);
$previewManager = $this->createMock(IPreview::class);
$this->templateManager = new TemplateManager(