Skip to content

Commit 1dbaf17

Browse files
authored
Merge pull request #56496 from nextcloud/carl/rector
Run rector on lib/private
2 parents 9def7a8 + 9a26169 commit 1dbaf17

File tree

471 files changed

+3517
-5691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+3517
-5691
lines changed

apps/dav/lib/CalDAV/Security/RateLimitingPlugin.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@
2424

2525
class RateLimitingPlugin extends ServerPlugin {
2626

27-
private Limiter $limiter;
28-
2927
public function __construct(
30-
Limiter $limiter,
28+
private Limiter $limiter,
3129
private IUserManager $userManager,
3230
private CalDavBackend $calDavBackend,
3331
private LoggerInterface $logger,
3432
private IAppConfig $config,
3533
private ?string $userId,
3634
) {
37-
$this->limiter = $limiter;
3835
}
3936

4037
public function initialize(DAV\Server $server): void {

apps/dav/lib/Connector/Sabre/Principal.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ class Principal implements BackendInterface {
4242
/** @var bool */
4343
private $hasCircles;
4444

45-
/** @var KnownUserService */
46-
private $knownUserService;
47-
4845
public function __construct(
4946
private IUserManager $userManager,
5047
private IGroupManager $groupManager,
@@ -53,14 +50,13 @@ public function __construct(
5350
private IUserSession $userSession,
5451
private IAppManager $appManager,
5552
private ProxyMapper $proxyMapper,
56-
KnownUserService $knownUserService,
53+
private KnownUserService $knownUserService,
5754
private IConfig $config,
5855
private IFactory $languageFactory,
5956
string $principalPrefix = 'principals/users/',
6057
) {
6158
$this->principalPrefix = trim($principalPrefix, '/');
6259
$this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/');
63-
$this->knownUserService = $knownUserService;
6460
}
6561

6662
use PrincipalProxyTrait {

apps/dav/lib/Connector/Sabre/TagsPlugin.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
4949
* @var \Sabre\DAV\Server
5050
*/
5151
private $server;
52-
53-
/**
54-
* @var ITags
55-
*/
56-
private $tagger;
52+
private ?ITags $tagger = null;
5753

5854
/**
5955
* Array of file id to tags array
@@ -105,11 +101,17 @@ public function initialize(\Sabre\DAV\Server $server) {
105101
*
106102
* @return ITags tagger
107103
*/
108-
private function getTagger() {
109-
if (!$this->tagger) {
110-
$this->tagger = $this->tagManager->load('files');
104+
private function getTagger(): ITags {
105+
if ($this->tagger) {
106+
return $this->tagger;
107+
}
108+
109+
$tagger = $this->tagManager->load('files');
110+
if ($tagger === null) {
111+
throw new \RuntimeException('Tagger not found for files');
111112
}
112-
return $this->tagger;
113+
$this->tagger = $tagger;
114+
return $tagger;
113115
}
114116

115117
/**

apps/dav/lib/Migration/RemoveObjectProperties.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,16 @@ class RemoveObjectProperties implements IRepairStep {
1616
private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card';
1717
private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp';
1818

19-
/**
20-
* RemoveObjectProperties constructor.
21-
*
22-
* @param IDBConnection $connection
23-
*/
2419
public function __construct(
25-
private IDBConnection $connection,
20+
private readonly IDBConnection $connection,
2621
) {
2722
}
2823

29-
/**
30-
* @inheritdoc
31-
*/
32-
public function getName() {
24+
public function getName(): string {
3325
return 'Remove invalid object properties';
3426
}
3527

36-
/**
37-
* @inheritdoc
38-
*/
39-
public function run(IOutput $output) {
28+
public function run(IOutput $output): void {
4029
$query = $this->connection->getQueryBuilder();
4130
$updated = $query->delete('properties')
4231
->where($query->expr()->in('propertyname', $query->createNamedParameter([self::RESOURCE_TYPE_PROPERTY, self::ME_CARD_PROPERTY, self::CALENDAR_TRANSP_PROPERTY], IQueryBuilder::PARAM_STR_ARRAY)))

apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,17 @@ class AppleProvisioningPlugin extends ServerPlugin {
2222
*/
2323
protected $server;
2424

25-
/**
26-
* @var \OC_Defaults
27-
*/
28-
protected $themingDefaults;
29-
3025
/**
3126
* AppleProvisioningPlugin constructor.
3227
*/
3328
public function __construct(
3429
protected IUserSession $userSession,
3530
protected IURLGenerator $urlGenerator,
36-
\OC_Defaults $themingDefaults,
31+
protected \OC_Defaults $themingDefaults,
3732
protected IRequest $request,
3833
protected IL10N $l10n,
3934
protected \Closure $uuidClosure,
4035
) {
41-
$this->themingDefaults = $themingDefaults;
4236
}
4337

4438
/**

apps/dav/lib/SystemTag/SystemTagsInUseCollection.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@
2222
use Sabre\DAV\SimpleCollection;
2323

2424
class SystemTagsInUseCollection extends SimpleCollection {
25-
protected SystemTagsInFilesDetector $systemTagsInFilesDetector;
26-
2725
/** @noinspection PhpMissingParentConstructorInspection */
2826
public function __construct(
2927
protected IUserSession $userSession,
3028
protected IRootFolder $rootFolder,
3129
protected ISystemTagManager $systemTagManager,
3230
protected ISystemTagObjectMapper $tagMapper,
33-
SystemTagsInFilesDetector $systemTagsInFilesDetector,
31+
protected SystemTagsInFilesDetector $systemTagsInFilesDetector,
3432
protected string $mediaType = '',
3533
) {
36-
$this->systemTagsInFilesDetector = $systemTagsInFilesDetector;
3734
$this->name = 'systemtags-assigned';
3835
if ($this->mediaType != '') {
3936
$this->name .= '/' . $this->mediaType;

apps/dav/tests/unit/Connector/LegacyPublicAuthTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
use OCP\Share\Exceptions\ShareNotFound;
1616
use OCP\Share\IManager;
1717
use OCP\Share\IShare;
18+
use PHPUnit\Framework\Attributes\Group;
1819
use PHPUnit\Framework\MockObject\MockObject;
20+
use Test\TestCase;
1921

20-
/**
21-
* Class LegacyPublicAuthTest
22-
*
23-
*
24-
* @package OCA\DAV\Tests\unit\Connector
25-
*/
26-
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
27-
class LegacyPublicAuthTest extends \Test\TestCase {
22+
#[Group(name: 'DB')]
23+
class LegacyPublicAuthTest extends TestCase {
2824
private ISession&MockObject $session;
2925
private IRequest&MockObject $request;
3026
private IManager&MockObject $shareManager;
@@ -55,7 +51,7 @@ protected function tearDown(): void {
5551
\OC_User::setIncognitoMode(false);
5652

5753
// Set old user
58-
\OC_User::setUserId($this->oldUser);
54+
\OC_User::setUserId($this->oldUser ?: null);
5955
if ($this->oldUser !== false) {
6056
\OC_Util::setupFS($this->oldUser);
6157
}

apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testGetPrincipalsByPrefixWithoutPrefix(): void {
7878
}
7979

8080
public function testGetPrincipalsByPrefixWithUsers(): void {
81-
$fooUser = $this->createMock(User::class);
81+
$fooUser = $this->createMock(IUser::class);
8282
$fooUser
8383
->expects($this->once())
8484
->method('getUID')
@@ -91,7 +91,7 @@ public function testGetPrincipalsByPrefixWithUsers(): void {
9191
->expects($this->once())
9292
->method('getSystemEMailAddress')
9393
->willReturn('');
94-
$barUser = $this->createMock(User::class);
94+
$barUser = $this->createMock(IUser::class);
9595
$barUser
9696
->expects($this->once())
9797
->method('getUID')
@@ -183,7 +183,7 @@ public function testGetPrincipalsByPrefixEmpty(): void {
183183
}
184184

185185
public function testGetPrincipalsByPathWithoutMail(): void {
186-
$fooUser = $this->createMock(User::class);
186+
$fooUser = $this->createMock(IUser::class);
187187
$fooUser
188188
->expects($this->once())
189189
->method('getUID')
@@ -211,7 +211,7 @@ public function testGetPrincipalsByPathWithoutMail(): void {
211211
}
212212

213213
public function testGetPrincipalsByPathWithMail(): void {
214-
$fooUser = $this->createMock(User::class);
214+
$fooUser = $this->createMock(IUser::class);
215215
$fooUser
216216
->expects($this->once())
217217
->method('getSystemEMailAddress')

apps/federatedfilesharing/lib/Notifications.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OCA\FederatedFileSharing;
99

10+
use OC\ServerNotAvailableException;
1011
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
1112
use OCP\AppFramework\Http;
1213
use OCP\BackgroundJob\IJobList;
@@ -47,7 +48,7 @@ public function __construct(
4748
* @param int $shareType (can be a remote user or group share)
4849
* @return bool
4950
* @throws HintException
50-
* @throws \OC\ServerNotAvailableException
51+
* @throws ServerNotAvailableException
5152
*/
5253
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
5354
[$user, $remote] = $this->addressHandler->splitUserRemote($shareWith);
@@ -106,7 +107,7 @@ public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $o
106107
* @param string $filename
107108
* @return array|false
108109
* @throws HintException
109-
* @throws \OC\ServerNotAvailableException
110+
* @throws ServerNotAvailableException
110111
*/
111112
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename, $shareType) {
112113
$fields = [

apps/federation/lib/SyncFederationAddressBooks.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,18 @@
77
*/
88
namespace OCA\Federation;
99

10-
use OC\OCS\DiscoveryService;
1110
use OCA\DAV\CardDAV\SyncService;
1211
use OCP\AppFramework\Http;
1312
use OCP\OCS\IDiscoveryService;
1413
use Psr\Log\LoggerInterface;
1514

1615
class SyncFederationAddressBooks {
17-
private DiscoveryService $ocsDiscoveryService;
18-
1916
public function __construct(
2017
protected DbHandler $dbHandler,
2118
private SyncService $syncService,
22-
IDiscoveryService $ocsDiscoveryService,
19+
private IDiscoveryService $ocsDiscoveryService,
2320
private LoggerInterface $logger,
2421
) {
25-
$this->ocsDiscoveryService = $ocsDiscoveryService;
2622
}
2723

2824
/**

0 commit comments

Comments
 (0)