Skip to content

Commit f9261aa

Browse files
committed
chore: update composer to fix psalm
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 36148d3 commit f9261aa

16 files changed

Lines changed: 344 additions & 269 deletions

composer.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"name": "nextcloud/guests",
33
"config": {
4-
"optimize-autoloader": true,
5-
"classmap-authoritative": true,
64
"platform": {
7-
"php": "8.1.0"
5+
"php": "8.1"
6+
},
7+
"sort-packages": true,
8+
"allow-plugins": {
9+
"bamarni/composer-bin-plugin": true
810
},
9-
"sort-packages": true
11+
"optimize-autoloader": true,
12+
"autoloader-suffix": "Guests"
1013
},
11-
"autoload-dev": {
14+
"autoload": {
1215
"psr-4": {
13-
"OCP\\": "vendor/nextcloud/ocp/OCP"
16+
"OCA\\Guests\\": "lib/"
1417
}
1518
},
1619
"scripts": {
@@ -20,14 +23,17 @@
2023
"psalm": "psalm --threads=1",
2124
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
2225
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
23-
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
26+
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MismatchingDocblockParamType,MismatchingDocblockReturnType,MissingParamType,InvalidFalsableReturnType",
2427
"test:unit": "vendor/bin/phpunit -c phpunit.xml"
2528
},
29+
"require": {
30+
"php": ">=8.1 <=8.4"
31+
},
2632
"require-dev": {
2733
"nextcloud/coding-standard": "^1.3.2",
2834
"nextcloud/ocp": "dev-master",
2935
"php-parallel-lint/php-parallel-lint": "^1.2",
3036
"phpunit/phpunit": "^9",
31-
"vimeo/psalm": "^5.14"
37+
"vimeo/psalm": "^5.26.1"
3238
}
3339
}

composer.lock

Lines changed: 197 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/AppConfigOverwrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function setOverwrite(array $overwrite): void {
2222
/**
2323
* @psalm-suppress MethodSignatureMustProvideReturnType
2424
*/
25-
public function getValue($app, $key, $default = null) {
25+
public function getValue($app, $key, $default = null): string {
2626
if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) {
2727
return $this->overWrite[$app][$key];
2828
}

lib/AppWhitelist.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151
$this->baseUrlLength = strlen($this->baseUrl);
5252
}
5353

54-
public function isAppWhitelisted($appId): bool {
54+
public function isAppWhitelisted(string $appId): bool {
5555
$whitelist = $this->config->getAppWhitelist();
5656
$alwaysEnabled = explode(',', self::WHITELIST_ALWAYS);
5757

@@ -62,7 +62,10 @@ public function isWhitelistEnabled(): bool {
6262
return $this->config->useWhitelist();
6363
}
6464

65-
public function isUrlAllowed(IUser $user, $url): bool {
65+
/**
66+
* @param false|string $url
67+
*/
68+
public function isUrlAllowed(IUser $user, string|false $url): bool {
6669
if ($this->guestManager->isGuest($user) && $this->isWhitelistEnabled()) {
6770
$app = $this->getRequestedApp($url);
6871

@@ -95,8 +98,10 @@ public function verifyAccess(IUser $user, IRequest $request): void {
9598
/**
9699
* Core has \OC::$REQUESTEDAPP but it isn't set until the routes are matched
97100
* taken from \OC\Route\Router::match()
101+
*
102+
* @param false|string $url
98103
*/
99-
private function getRequestedApp($url): string {
104+
private function getRequestedApp(string|false $url): string {
100105
if (substr($url, 0, $this->baseUrlLength) === $this->baseUrl) {
101106
$url = substr($url, $this->baseUrlLength);
102107
}

lib/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function allowExternalStorage(): bool {
3131
/**
3232
* @param string|bool $allow
3333
*/
34-
public function setAllowExternalStorage($allow) {
34+
public function setAllowExternalStorage($allow): void {
3535
$this->appConfig->setAppValueBool('allow_external_storage', $allow === true || $allow === 'true') ;
3636
}
3737

@@ -57,7 +57,7 @@ public function useWhitelist(): bool {
5757
/**
5858
* @param string|bool $use
5959
*/
60-
public function setUseWhitelist($use) {
60+
public function setUseWhitelist($use): void {
6161
$this->appConfig->setAppValueBool('usewhitelist', $use === true || $use === 'true') ;
6262
}
6363

lib/FilteredSettingsManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ private function isSettingAllowed(string $setting): bool {
2828
return $this->appWhitelist->isAppWhitelisted($appId);
2929
}
3030

31+
/**
32+
* @return void
33+
*/
3134
public function registerSection(string $type, string $section) {
3235
$this->manager->registerSection($type, $section);
3336
}
3437

38+
/**
39+
* @return void
40+
*/
3541
public function registerSetting(string $type, string $setting) {
3642
if (!$this->isSettingAllowed($setting)) {
3743
return;

lib/GroupBackend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function inGroup($uid, $gid): bool {
7373
* Get all groups a user belongs to
7474
*
7575
* @param string $uid Name of the user
76-
* @return array an array of group names
76+
* @return list<string> an array of group names
7777
* @since 4.5.0
7878
*
7979
* This function fetches all groups a user belongs to. It does not check
@@ -120,7 +120,7 @@ public function groupExists($gid): bool {
120120
* @param string $search
121121
* @param int $limit
122122
* @param int $offset
123-
* @return array an array of user ids
123+
* @return array<int, string> an array of user ids
124124
* @since 4.5.0
125125
*/
126126
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0): array {

lib/GuestManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function getShareCountForUsers(array $guests): array {
149149
return $data;
150150
}
151151

152-
public function getGuestInfo($userId): array {
152+
public function getGuestInfo(string $userId): array {
153153
$shares = array_merge(
154154
$this->shareManager->getSharedWith($userId, IShare::TYPE_USER, null, -1, 0),
155155
$this->shareManager->getSharedWith($userId, IShare::TYPE_GROUP, null, -1, 0),

lib/Listener/BeforeUserManagementRenderedListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* @template-implements IEventListener<BeforeTemplateRenderedEvent>
1919
*/
2020
class BeforeUserManagementRenderedListener implements IEventListener {
21+
/**
22+
* @param Event $event
23+
*/
2124
public function handle(Event $event): void {
2225
if (!($event instanceof BeforeTemplateRenderedEvent)) {
2326
return;

lib/Listener/LoadAdditionalScriptsListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct(
2626
) {
2727
}
2828

29+
/**
30+
* @param Event $event
31+
*/
2932
public function handle(Event $event): void {
3033
// If the user cannot create guests, we don't need to load the script
3134
if (!$this->config->canCreateGuests()) {

0 commit comments

Comments
 (0)