Skip to content

Commit a87636a

Browse files
committed
chore(psalm): Apply MissingOverrideAttribute fix from psalm
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 3b687ec commit a87636a

64 files changed

Lines changed: 153 additions & 1 deletion

File tree

Some content is hidden

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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"cs:fix": "php-cs-fixer fix",
1818
"psalm": "psalm --threads=$(nproc) --no-cache",
1919
"psalm:update-baseline": "psalm --threads=$(nproc) --no-cache --update-baseline",
20-
"psalm:fix": "psalm --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
20+
"psalm:fix": "psalm --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType,MissingOverrideAttribute",
2121
"test:unit": "phpunit -c tests/phpunit.xml",
2222
"test:unit:coverage": "XDEBUG_MODE=coverage phpunit -c tests/phpunit.xml",
2323
"rector": "rector && composer cs:fix",

lib/ACL/ACLCacheWrapper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private function getACLPermissionsForPath(string $path, array $rules = []): int
4343
return $canRead ? $permissions : 0;
4444
}
4545

46+
#[\Override]
4647
protected function formatCacheEntry($entry, array $rules = []): ICacheEntry|false {
4748
if (isset($entry['permissions'])) {
4849
$entry['scan_permissions'] ??= $entry['permissions'];
@@ -55,27 +56,31 @@ protected function formatCacheEntry($entry, array $rules = []): ICacheEntry|fals
5556
return $entry;
5657
}
5758

59+
#[\Override]
5860
public function getFolderContentsById($fileId): array {
5961
$results = $this->getCache()->getFolderContentsById($fileId);
6062
$rules = $this->preloadEntries($results);
6163

6264
return array_filter(array_map(fn (ICacheEntry $entry): ICacheEntry|false => $this->formatCacheEntry($entry, $rules), $results));
6365
}
6466

67+
#[\Override]
6568
public function search($pattern): array {
6669
$results = $this->getCache()->search($pattern);
6770
$this->preloadEntries($results);
6871

6972
return array_filter(array_map($this->formatCacheEntry(...), $results));
7073
}
7174

75+
#[\Override]
7276
public function searchByMime($mimetype): array {
7377
$results = $this->getCache()->searchByMime($mimetype);
7478
$this->preloadEntries($results);
7579

7680
return array_filter(array_map($this->formatCacheEntry(...), $results));
7781
}
7882

83+
#[\Override]
7984
public function searchQuery(ISearchQuery $query): array {
8085
$results = $this->getCache()->searchQuery($query);
8186
$this->preloadEntries($results);

lib/ACL/ACLStorageWrapper.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,39 @@ private function checkPermissions(string $path, int $permissions): bool {
4747
return ($this->getACLPermissionsForPath($path) & $permissions) === $permissions;
4848
}
4949

50+
#[\Override]
5051
public function isReadable(string $path): bool {
5152
return $this->checkPermissions($path, Constants::PERMISSION_READ) && parent::isReadable($path);
5253
}
5354

55+
#[\Override]
5456
public function isUpdatable(string $path): bool {
5557
return $this->checkPermissions($path, Constants::PERMISSION_UPDATE) && parent::isUpdatable($path);
5658
}
5759

60+
#[\Override]
5861
public function isCreatable(string $path): bool {
5962
return $this->checkPermissions($path, Constants::PERMISSION_CREATE) && parent::isCreatable($path);
6063
}
6164

65+
#[\Override]
6266
public function isDeletable(string $path): bool {
6367
return $this->checkPermissions($path, Constants::PERMISSION_DELETE)
6468
&& $this->canDeleteTree($path)
6569
&& parent::isDeletable($path);
6670
}
6771

72+
#[\Override]
6873
public function isSharable(string $path): bool {
6974
return $this->checkPermissions($path, Constants::PERMISSION_SHARE) && parent::isSharable($path);
7075
}
7176

77+
#[\Override]
7278
public function getPermissions(string $path): int {
7379
return $this->storage->getPermissions($path) & $this->getACLPermissionsForPath($path);
7480
}
7581

82+
#[\Override]
7683
public function rename(string $source, string $target): bool {
7784
if (str_starts_with($source, $target)) {
7885
$part = substr($source, strlen($target));
@@ -100,6 +107,7 @@ public function rename(string $source, string $target): bool {
100107
&& parent::rename($source, $target);
101108
}
102109

110+
#[\Override]
103111
public function opendir(string $path) {
104112
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
105113
return false;
@@ -122,28 +130,33 @@ public function opendir(string $path) {
122130
return IteratorDirectory::wrap($items);
123131
}
124132

133+
#[\Override]
125134
public function copy(string $source, string $target): bool {
126135
$permissions = $this->file_exists($target) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE;
127136
return $this->checkPermissions($target, $permissions)
128137
&& $this->checkPermissions($source, Constants::PERMISSION_READ)
129138
&& parent::copy($source, $target);
130139
}
131140

141+
#[\Override]
132142
public function touch(string $path, ?int $mtime = null): bool {
133143
$permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE;
134144
return $this->checkPermissions($path, $permissions) && parent::touch($path, $mtime);
135145
}
136146

147+
#[\Override]
137148
public function mkdir(string $path): bool {
138149
return $this->checkPermissions($path, Constants::PERMISSION_CREATE) && parent::mkdir($path);
139150
}
140151

152+
#[\Override]
141153
public function rmdir(string $path): bool {
142154
return $this->checkPermissions($path, Constants::PERMISSION_DELETE)
143155
&& $this->canDeleteTree($path)
144156
&& parent::rmdir($path);
145157
}
146158

159+
#[\Override]
147160
public function unlink(string $path): bool {
148161
return $this->checkPermissions($path, Constants::PERMISSION_DELETE)
149162
&& $this->canDeleteTree($path)
@@ -158,11 +171,13 @@ private function canDeleteTree(string $path): int {
158171
return $this->aclManager->getPermissionsForTree($this->folderId, $this->storageId, $path) & Constants::PERMISSION_DELETE;
159172
}
160173

174+
#[\Override]
161175
public function file_put_contents(string $path, mixed $data): int|float|false {
162176
$permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE;
163177
return $this->checkPermissions($path, $permissions) ? parent::file_put_contents($path, $data) : false;
164178
}
165179

180+
#[\Override]
166181
public function fopen(string $path, string $mode) {
167182
if ($mode === 'r' or $mode === 'rb') {
168183
$permissions = Constants::PERMISSION_READ;
@@ -173,6 +188,7 @@ public function fopen(string $path, string $mode) {
173188
return $this->checkPermissions($path, $permissions) ? parent::fopen($path, $mode) : false;
174189
}
175190

191+
#[\Override]
176192
public function writeStream(string $path, $stream, ?int $size = null): int {
177193
$permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE;
178194
return $this->checkPermissions($path, $permissions) ? parent::writeStream($path, $stream, $size) : 0;
@@ -181,6 +197,7 @@ public function writeStream(string $path, $stream, ?int $size = null): int {
181197
/**
182198
* @inheritDoc
183199
*/
200+
#[\Override]
184201
public function getCache(string $path = '', ?IStorage $storage = null): ICache {
185202
if (!$storage) {
186203
$storage = $this;
@@ -191,6 +208,7 @@ public function getCache(string $path = '', ?IStorage $storage = null): ICache {
191208
return new ACLCacheWrapper($sourceCache, $this->aclManager, $this->folderId, $this->inShare);
192209
}
193210

211+
#[\Override]
194212
public function getMetaData(string $path): ?array {
195213
$data = parent::getMetaData($path);
196214

@@ -205,6 +223,7 @@ public function getMetaData(string $path): ?array {
205223
/**
206224
* @inheritDoc
207225
*/
226+
#[\Override]
208227
public function getScanner(string $path = '', ?IStorage $storage = null): IScanner {
209228
if (!$storage) {
210229
$storage = $this->storage;
@@ -213,16 +232,19 @@ public function getScanner(string $path = '', ?IStorage $storage = null): IScann
213232
return parent::getScanner($path, $storage);
214233
}
215234

235+
#[\Override]
216236
public function is_dir(string $path): bool {
217237
return $this->checkPermissions($path, Constants::PERMISSION_READ)
218238
&& parent::is_dir($path);
219239
}
220240

241+
#[\Override]
221242
public function is_file(string $path): bool {
222243
return $this->checkPermissions($path, Constants::PERMISSION_READ)
223244
&& parent::is_file($path);
224245
}
225246

247+
#[\Override]
226248
public function stat(string $path): array|false {
227249
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
228250
return false;
@@ -231,6 +253,7 @@ public function stat(string $path): array|false {
231253
return parent::stat($path);
232254
}
233255

256+
#[\Override]
234257
public function filetype(string $path): string|false {
235258
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
236259
return false;
@@ -239,6 +262,7 @@ public function filetype(string $path): string|false {
239262
return parent::filetype($path);
240263
}
241264

265+
#[\Override]
242266
public function filesize(string $path): false|int|float {
243267
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
244268
return false;
@@ -247,11 +271,13 @@ public function filesize(string $path): false|int|float {
247271
return parent::filesize($path);
248272
}
249273

274+
#[\Override]
250275
public function file_exists(string $path): bool {
251276
return $this->checkPermissions($path, Constants::PERMISSION_READ)
252277
&& parent::file_exists($path);
253278
}
254279

280+
#[\Override]
255281
public function filemtime(string $path): int|false {
256282
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
257283
return false;
@@ -260,6 +286,7 @@ public function filemtime(string $path): int|false {
260286
return parent::filemtime($path);
261287
}
262288

289+
#[\Override]
263290
public function file_get_contents(string $path): string|false {
264291
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
265292
return false;
@@ -268,6 +295,7 @@ public function file_get_contents(string $path): string|false {
268295
return parent::file_get_contents($path);
269296
}
270297

298+
#[\Override]
271299
public function getMimeType(string $path): string|false {
272300
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
273301
return false;
@@ -276,6 +304,7 @@ public function getMimeType(string $path): string|false {
276304
return parent::getMimeType($path);
277305
}
278306

307+
#[\Override]
279308
public function hash(string $type, string $path, bool $raw = false): string|false {
280309
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
281310
return false;
@@ -284,6 +313,7 @@ public function hash(string $type, string $path, bool $raw = false): string|fals
284313
return parent::hash($type, $path, $raw);
285314
}
286315

316+
#[\Override]
287317
public function getETag(string $path): string|false {
288318
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
289319
return false;
@@ -292,6 +322,7 @@ public function getETag(string $path): string|false {
292322
return parent::getETag($path);
293323
}
294324

325+
#[\Override]
295326
public function getDirectDownload(string $path): array|false {
296327
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
297328
return false;
@@ -300,6 +331,7 @@ public function getDirectDownload(string $path): array|false {
300331
return parent::getDirectDownload($path);
301332
}
302333

334+
#[\Override]
303335
public function getDirectoryContent(string $directory): \Traversable {
304336
$content = $this->getWrapperStorage()->getDirectoryContent($directory);
305337
foreach ($content as $data) {

lib/ACL/Rule.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function applyDenyPermissions(int $permissions): int {
9595
return $permissions & $denyMask;
9696
}
9797

98+
#[\Override]
9899
public function xmlSerialize(Writer $writer): void {
99100
$data = [
100101
self::ACL => [
@@ -108,6 +109,7 @@ public function xmlSerialize(Writer $writer): void {
108109
$writer->write($data);
109110
}
110111

112+
#[\Override]
111113
public function jsonSerialize(): array {
112114
return [
113115
'mapping' => [
@@ -119,6 +121,7 @@ public function jsonSerialize(): array {
119121
];
120122
}
121123

124+
#[\Override]
122125
public static function xmlDeserialize(Reader $reader): Rule {
123126
$elements = \Sabre\Xml\Deserializer\keyValue($reader);
124127

lib/ACL/UserMapping/UserMapping.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ public function __construct(
2222
$this->displayName = $displayName ?? $id;
2323
}
2424

25+
#[\Override]
2526
public function getType(): string {
2627
return $this->type;
2728
}
2829

30+
#[\Override]
2931
public function getId(): string {
3032
return $this->id;
3133
}
3234

35+
#[\Override]
3336
public function getDisplayName(): string {
3437
return $this->displayName;
3538
}
3639

40+
#[\Override]
3741
public function getKey(): string {
3842
return $this->getType() . ':' . $this->getId();
3943
}

lib/ACL/UserMapping/UserMappingManager.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(
2929
) {
3030
}
3131

32+
#[\Override]
3233
public function getMappingsForUser(IUser $user, bool $userAssignable = true): array {
3334
$groupMappings = array_values(array_map(fn (IGroup $group): UserMapping => new UserMapping('group', $group->getGID(), $group->getDisplayName()), $this->groupManager->getUserGroups($user)));
3435
$circleMappings = array_values(array_map(fn (Circle $circle): UserMapping => new UserMapping('circle', $circle->getSingleId(), $circle->getDisplayName()), $this->getUserCircles($user->getUID())));
@@ -38,6 +39,7 @@ public function getMappingsForUser(IUser $user, bool $userAssignable = true): ar
3839
], $groupMappings, $circleMappings);
3940
}
4041

42+
#[\Override]
4143
public function mappingFromId(string $type, string $id): ?IUserMapping {
4244
switch ($type) {
4345
case 'group':
@@ -115,6 +117,7 @@ public function getCirclesManager(): ?CirclesManager {
115117
}
116118
}
117119

120+
#[\Override]
118121
public function userInMappings(IUser $user, array $mappings): bool {
119122
foreach ($mappings as $mapping) {
120123
if ($mapping->getType() === 'user' && $mapping->getId() === $user->getUID()) {

lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function __construct(array $urlParams = []) {
6868
'workspace'
6969
];
7070

71+
#[\Override]
7172
public function register(IRegistrationContext $context): void {
7273
/** Register $principalBackend for the DAV collection */
7374
$context->registerServiceAlias('principalBackend', Principal::class);
@@ -184,6 +185,7 @@ public function register(IRegistrationContext $context): void {
184185
$context->registerMiddleware(AuthorizedAdminSettingMiddleware::class);
185186
}
186187

188+
#[\Override]
187189
public function boot(IBootContext $context): void {
188190
$context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, IEventDispatcher $eventDispatcher): void {
189191
$mountProviderCollection->registerProvider(Server::get(MountProvider::class));

lib/AppInfo/Capabilities.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(
2929
* },
3030
* }
3131
*/
32+
#[\Override]
3233
public function getCapabilities(): array {
3334
$user = $this->userSession->getUser();
3435
if (!$user) {

lib/AuthorizedAdminSettingMiddleware.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ public function __construct(
3030
/**
3131
* Throws an error when the user is not allowed to use the app's APIs
3232
*/
33+
#[\Override]
3334
public function beforeController(Controller $controller, string $methodName): void {
3435
$method = new ReflectionMethod($controller, $methodName);
3536
if ($method->getAttributes(RequireGroupFolderAdmin::class) !== [] && !$this->delegatedService->hasApiAccess()) {
3637
throw new Exception('Logged in user must be an admin, a sub admin or gotten special right to access this setting');
3738
}
3839
}
3940

41+
#[\Override]
4042
public function afterException(Controller $controller, string $methodName, Exception $exception): Response {
4143
/** @var Http::STATUS_* $code */
4244
$code = $exception->getCode();

lib/BackgroundJob/ExpireGroupPlaceholder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(ITimeFactory $timeFactory) {
1818
$this->setInterval(60 * 60 * 99999999);
1919
}
2020

21+
#[\Override]
2122
protected function run(mixed $argument): void {
2223
// noop
2324
}

0 commit comments

Comments
 (0)