Skip to content

Commit 22cc35c

Browse files
committed
refactor: Run rector on lib/private
Signed-off-by: Carl Schwan <[email protected]>
1 parent 3cd0f70 commit 22cc35c

File tree

380 files changed

+2706
-3410
lines changed

Some content is hidden

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

380 files changed

+2706
-3410
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function initialize(\Sabre\DAV\Server $server) {
108108
private function getTagger() {
109109
if (!$this->tagger) {
110110
$this->tagger = $this->tagManager->load('files');
111+
assert($this->tagger !== null);
111112
}
112113
return $this->tagger;
113114
}

apps/files_sharing/lib/External/Scanner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
use OCP\Files\StorageInvalidException;
1414
use OCP\Files\StorageNotAvailableException;
1515

16+
/**
17+
* @property Storage $storage
18+
*/
1619
class Scanner extends \OC\Files\Cache\Scanner {
17-
/** @var Storage */
18-
protected $storage;
19-
2020
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
2121
// Disable locking for federated shares
2222
parent::scan($path, $recursive, $reuse, false);

apps/files_sharing/lib/Scanner.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@
1010

1111
use OC\Files\ObjectStore\ObjectStoreScanner;
1212
use OC\Files\Storage\Storage;
13+
use OCP\Files\Cache\IScanner;
1314

1415
/**
1516
* Scanner for SharedStorage
17+
* @property SharedStorage $storage
1618
*/
1719
class Scanner extends \OC\Files\Cache\Scanner {
18-
/**
19-
* @var SharedStorage $storage
20-
*/
21-
protected $storage;
22-
23-
private $sourceScanner;
20+
private ?IScanner $sourceScanner = null;
2421

2522
/**
2623
* Returns metadata from the shared storage, but
@@ -40,7 +37,7 @@ public function getData($path) {
4037
return $data;
4138
}
4239

43-
private function getSourceScanner() {
40+
private function getSourceScanner(): ?IScanner {
4441
if ($this->sourceScanner) {
4542
return $this->sourceScanner;
4643
}

build/psalm-baseline.xml

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3327,14 +3327,6 @@
33273327
<code><![CDATA[getName]]></code>
33283328
</UndefinedMethod>
33293329
</file>
3330-
<file src="lib/private/AppFramework/DependencyInjection/DIContainer.php">
3331-
<InvalidReturnStatement>
3332-
<code><![CDATA[$this->server]]></code>
3333-
</InvalidReturnStatement>
3334-
<InvalidReturnType>
3335-
<code><![CDATA[\OCP\IServerContainer]]></code>
3336-
</InvalidReturnType>
3337-
</file>
33383330
<file src="lib/private/AppFramework/Http/Output.php">
33393331
<InvalidReturnStatement>
33403332
<code><![CDATA[@readfile($path)]]></code>
@@ -3374,9 +3366,6 @@
33743366
<NoInterfaceProperties>
33753367
<code><![CDATA[$this->request->server]]></code>
33763368
</NoInterfaceProperties>
3377-
<UndefinedClass>
3378-
<code><![CDATA[\OCA\Talk\Controller\PageController]]></code>
3379-
</UndefinedClass>
33803369
</file>
33813370
<file src="lib/private/AppFramework/Services/AppConfig.php">
33823371
<MoreSpecificImplementedParamType>
@@ -3739,18 +3728,6 @@
37393728
<code><![CDATA[array{int, string, int}]]></code>
37403729
</MoreSpecificReturnType>
37413730
</file>
3742-
<file src="lib/private/Files/Filesystem.php">
3743-
<LessSpecificReturnStatement>
3744-
<code><![CDATA[$mount->getStorage()]]></code>
3745-
<code><![CDATA[self::getMountManager()->findByNumericId($id)]]></code>
3746-
<code><![CDATA[self::getMountManager()->findByStorageId($id)]]></code>
3747-
</LessSpecificReturnStatement>
3748-
<MoreSpecificReturnType>
3749-
<code><![CDATA[Mount\MountPoint[]]]></code>
3750-
<code><![CDATA[Mount\MountPoint[]]]></code>
3751-
<code><![CDATA[\OC\Files\Storage\Storage|null]]></code>
3752-
</MoreSpecificReturnType>
3753-
</file>
37543731
<file src="lib/private/Files/Mount/MountPoint.php">
37553732
<UndefinedInterfaceMethod>
37563733
<code><![CDATA[wrap]]></code>
@@ -3931,32 +3908,7 @@
39313908
<code><![CDATA[is_null($this->getContent())]]></code>
39323909
</TypeDoesNotContainNull>
39333910
</file>
3934-
<file src="lib/private/Group/Group.php">
3935-
<LessSpecificReturnStatement>
3936-
<code><![CDATA[$users]]></code>
3937-
</LessSpecificReturnStatement>
3938-
<MoreSpecificReturnType>
3939-
<code><![CDATA[\OC\User\User[]]]></code>
3940-
</MoreSpecificReturnType>
3941-
<RedundantCondition>
3942-
<code><![CDATA[$this->emitter]]></code>
3943-
<code><![CDATA[$this->emitter]]></code>
3944-
<code><![CDATA[$this->emitter]]></code>
3945-
</RedundantCondition>
3946-
<UndefinedMethod>
3947-
<code><![CDATA[addToGroup]]></code>
3948-
<code><![CDATA[countUsersInGroup]]></code>
3949-
<code><![CDATA[deleteGroup]]></code>
3950-
<code><![CDATA[removeFromGroup]]></code>
3951-
</UndefinedMethod>
3952-
</file>
39533911
<file src="lib/private/Group/Manager.php">
3954-
<LessSpecificReturnStatement>
3955-
<code><![CDATA[$groups]]></code>
3956-
</LessSpecificReturnStatement>
3957-
<MoreSpecificReturnType>
3958-
<code><![CDATA[\OC\Group\Group[]]]></code>
3959-
</MoreSpecificReturnType>
39603912
<UndefinedInterfaceMethod>
39613913
<code><![CDATA[createGroup]]></code>
39623914
<code><![CDATA[getGroupDetails]]></code>
@@ -4050,11 +4002,6 @@
40504002
<code><![CDATA[mixed]]></code>
40514003
</LessSpecificImplementedReturnType>
40524004
</file>
4053-
<file src="lib/private/Notification/Manager.php">
4054-
<UndefinedClass>
4055-
<code><![CDATA[\OCA\Notifications\App]]></code>
4056-
</UndefinedClass>
4057-
</file>
40584005
<file src="lib/private/Profile/Actions/FediverseAction.php">
40594006
<NoValue>
40604007
<code><![CDATA[$instance]]></code>
@@ -4116,25 +4063,6 @@
41164063
<code><![CDATA[setPassword]]></code>
41174064
</InternalMethod>
41184065
</file>
4119-
<file src="lib/private/Server.php">
4120-
<ImplementedReturnTypeMismatch>
4121-
<code><![CDATA[\OCP\Files\Folder|null]]></code>
4122-
</ImplementedReturnTypeMismatch>
4123-
<LessSpecificReturnStatement>
4124-
<code><![CDATA[$this->get(IFile::class)]]></code>
4125-
<code><![CDATA[$this->get(IGroupManager::class)]]></code>
4126-
<code><![CDATA[$this->get(IUserManager::class)]]></code>
4127-
<code><![CDATA[$this->get(IUserSession::class)]]></code>
4128-
<code><![CDATA[$this->get(\OCP\Encryption\IManager::class)]]></code>
4129-
</LessSpecificReturnStatement>
4130-
<MoreSpecificReturnType>
4131-
<code><![CDATA[\OC\Encryption\File]]></code>
4132-
<code><![CDATA[\OC\Encryption\Manager]]></code>
4133-
<code><![CDATA[\OC\Group\Manager]]></code>
4134-
<code><![CDATA[\OC\User\Manager]]></code>
4135-
<code><![CDATA[\OC\User\Session]]></code>
4136-
</MoreSpecificReturnType>
4137-
</file>
41384066
<file src="lib/private/ServerContainer.php">
41394067
<InvalidPropertyAssignmentValue>
41404068
<code><![CDATA[$this->hasNoAppContainer]]></code>
@@ -4183,9 +4111,6 @@
41834111
<InvalidArgument>
41844112
<code><![CDATA[$id]]></code>
41854113
</InvalidArgument>
4186-
<UndefinedClass>
4187-
<code><![CDATA[\OCA\Circles\Api\v1\Circles]]></code>
4188-
</UndefinedClass>
41894114
</file>
41904115
<file src="lib/private/Share20/ProviderFactory.php">
41914116
<InvalidReturnStatement>
@@ -4220,14 +4145,6 @@
42204145
<code><![CDATA[getSupportedApps]]></code>
42214146
</UndefinedInterfaceMethod>
42224147
</file>
4223-
<file src="lib/private/TagManager.php">
4224-
<InvalidNullableReturnType>
4225-
<code><![CDATA[\OCP\ITags]]></code>
4226-
</InvalidNullableReturnType>
4227-
<NullableReturnStatement>
4228-
<code><![CDATA[null]]></code>
4229-
</NullableReturnStatement>
4230-
</file>
42314148
<file src="lib/private/Tags.php">
42324149
<InvalidScalarArgument>
42334150
<code><![CDATA[$from]]></code>

build/rector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
6464
$nextcloudDir . '/remote.php',
6565
$nextcloudDir . '/status.php',
6666
$nextcloudDir . '/version.php',
67-
$nextcloudDir . '/lib/private/Share20/ProviderFactory.php',
68-
$nextcloudDir . '/lib/private/Template',
67+
$nextcloudDir . '/lib/private',
6968
$nextcloudDir . '/tests',
7069
// $nextcloudDir . '/config',
71-
// $nextcloudDir . '/lib',
7270
// $nextcloudDir . '/themes',
7371
])
7472
->withSkip([
7573
$nextcloudDir . '/apps/*/3rdparty/*',
7674
$nextcloudDir . '/apps/*/build/stubs/*',
7775
$nextcloudDir . '/apps/*/composer/*',
7876
$nextcloudDir . '/apps/*/config/*',
77+
$nextcloudDir . '/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php',
78+
$nextcloudDir . '/lib/private/Files/Node/*',
7979
// The mock classes are excluded, as the tests explicitly test the annotations which should not be migrated to attributes
8080
$nextcloudDir . '/tests/lib/AppFramework/Middleware/Mock/*',
8181
$nextcloudDir . '/tests/lib/AppFramework/Middleware/Security/Mock/*',

lib/private/Activity/EventMerger.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
use OCP\IL10N;
1212

1313
class EventMerger implements IEventMerger {
14-
/** @var IL10N */
15-
protected $l10n;
16-
1714
/**
1815
* @param IL10N $l10n
1916
*/
20-
public function __construct(IL10N $l10n) {
21-
$this->l10n = $l10n;
17+
public function __construct(
18+
protected IL10N $l10n,
19+
) {
2220
}
2321

2422
/**

lib/private/Activity/Manager.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use OCP\IUserSession;
2727
use OCP\RichObjectStrings\IRichTextFormatter;
2828
use OCP\RichObjectStrings\IValidator;
29+
use OCP\Server;
2930

3031
class Manager implements IManager {
3132

@@ -59,7 +60,7 @@ public function __construct(
5960
private $consumers = [];
6061

6162
/**
62-
* @return \OCP\Activity\IConsumer[]
63+
* @return IConsumer[]
6364
*/
6465
protected function getConsumers(): array {
6566
if (!empty($this->consumers)) {
@@ -183,7 +184,7 @@ public function registerFilter(string $filter): void {
183184
public function getFilters(): array {
184185
foreach ($this->filterClasses as $class => $false) {
185186
/** @var IFilter $filter */
186-
$filter = \OCP\Server::get($class);
187+
$filter = Server::get($class);
187188

188189
if (!$filter instanceof IFilter) {
189190
throw new \InvalidArgumentException('Invalid activity filter registered');
@@ -230,7 +231,7 @@ public function registerProvider(string $provider): void {
230231
public function getProviders(): array {
231232
foreach ($this->providerClasses as $class => $false) {
232233
/** @var IProvider $provider */
233-
$provider = \OCP\Server::get($class);
234+
$provider = Server::get($class);
234235

235236
if (!$provider instanceof IProvider) {
236237
throw new \InvalidArgumentException('Invalid activity provider registered');
@@ -264,7 +265,7 @@ public function registerSetting(string $setting): void {
264265
public function getSettings(): array {
265266
foreach ($this->settingsClasses as $class => $false) {
266267
/** @var ISetting $setting */
267-
$setting = \OCP\Server::get($class);
268+
$setting = Server::get($class);
268269

269270
if ($setting instanceof ISetting) {
270271
if (!$setting instanceof ActivitySettings) {

0 commit comments

Comments
 (0)