Skip to content

Commit fdbd39a

Browse files
authored
Merge pull request #60012 from nextcloud/chore/rector-psalm
chore: fix strict psalm and rector
2 parents ca4a81e + 75273a6 commit fdbd39a

6 files changed

Lines changed: 76 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OCP\PreConditionNotMetException;
2929
use OCP\Server;
3030
use OCP\Share\Exceptions\ShareNotFound;
31+
use OCP\Share\IAttributes;
3132
use OCP\Share\IManager;
3233
use RuntimeException;
3334
use Sabre\DAV\Exception;
@@ -297,7 +298,7 @@ public function getShareAttributes(): array {
297298
$attributes = [];
298299
if ($storage->instanceOfStorage(ISharedStorage::class)) {
299300
$attributes = $storage->getShare()->getAttributes();
300-
if ($attributes === null) {
301+
if (!$attributes instanceof IAttributes) {
301302
return [];
302303
}
303304

build/rector-strict.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
$nextcloudDir . '/lib/private/DB/QueryBuilder/TypedQueryBuilder.php',
2626
$nextcloudDir . '/lib/public/DB/QueryBuilder/ITypedQueryBuilder.php',
2727
])
28+
->withAutoloadPaths([
29+
// ensure rector properly autoload the public interfaces
30+
$nextcloudDir . '/lib/public',
31+
])
2832
->withPreparedSets(
2933
deadCode: true,
3034
codeQuality: true,

psalm-strict.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
findUnusedVariablesAndParams="true"
1616
phpVersion="8.2"
1717
>
18+
<plugins>
19+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
20+
</plugins>
1821
<projectFiles>
1922
<file name="core/BackgroundJobs/ExpirePreviewsJob.php"/>
2023
<file name="lib/public/IContainer.php"/>
@@ -34,7 +37,6 @@
3437
<file name="lib/public/Share/IShareHelper.php"/>
3538
<ignoreFiles>
3639
<directory name="apps/**/composer"/>
37-
<directory name="apps/**/tests"/>
3840
<directory name="lib/composer"/>
3941
<directory name="lib/l10n"/>
4042
<directory name="3rdparty"/>
@@ -43,6 +45,9 @@
4345
<extraFiles>
4446
<directory name="apps/dav/lib"/>
4547
<directory name="apps/settings/lib"/>
48+
<!-- As long as the files are not in the projectFiles list, we need to include them here to make psalm aware of our interfaces -->
49+
<directory name="lib/private"/>
50+
<directory name="lib/public"/>
4651
<directory name="3rdparty"/>
4752
</extraFiles>
4853
<stubs>

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<plugin filename="build/psalm/AppFrameworkTainter.php" />
2121
<plugin filename="build/psalm/AttributeNamedParameters.php" />
2222
<plugin filename="build/psalm/LogicalOperatorChecker.php" />
23+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
2324
</plugins>
2425
<projectFiles>
2526
<directory name="apps/admin_audit"/>

vendor-bin/psalm/composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"require": {
3-
"vimeo/psalm": "^6.16"
4-
},
52
"config": {
63
"platform": {
74
"php": "8.2.27"
85
},
96
"allow-plugins": {
107
"composer/package-versions-deprecated": true
118
}
9+
},
10+
"require": {
11+
"psalm/plugin-phpunit": "^0.19.7",
12+
"vimeo/psalm": "^6.16"
1213
}
1314
}

vendor-bin/psalm/composer.lock

Lines changed: 59 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)