Skip to content

Commit e67e50a

Browse files
Merge pull request #14286 from nextcloud/ci/noid/psalm6
ci: Update psalm to v6
2 parents 20bd1c9 + aee336b commit e67e50a

File tree

8 files changed

+1459
-307
lines changed

8 files changed

+1459
-307
lines changed

.github/workflows/psalm.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,49 @@ concurrency:
1414
group: psalm-${{ github.head_ref || github.run_id }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
static-analysis:
1922
runs-on: ubuntu-latest
2023

2124
name: static-psalm-analysis
2225
steps:
2326
- name: Checkout
24-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
persist-credentials: false
2530

2631
- name: Get php version
2732
id: versions
2833
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
2934

35+
- name: Check enforcement of minimum PHP version ${{ steps.versions.outputs.php-min }} in psalm.xml
36+
run: grep 'phpVersion="${{ steps.versions.outputs.php-min }}' psalm.xml
37+
3038
- name: Set up php${{ steps.versions.outputs.php-available }}
3139
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
3240
with:
3341
php-version: ${{ steps.versions.outputs.php-available }}
3442
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
3543
coverage: none
3644
ini-file: development
45+
# Temporary workaround for missing pcntl_* in PHP 8.3
46+
ini-values: disable_functions=
3747
env:
3848
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3949

4050
- name: Install dependencies
41-
run: composer i
51+
run: |
52+
composer remove nextcloud/ocp --dev
53+
composer i
4254
4355
- name: Check for vulnerable PHP dependencies
4456
run: composer require --dev roave/security-advisories:dev-latest
4557

58+
- name: Install nextcloud/ocp
59+
run: composer require --dev nextcloud/ocp:dev-${{ steps.versions.outputs.branches-max }} --ignore-platform-reqs --with-dependencies
60+
4661
- name: Run coding standards check
47-
run: composer run psalm
62+
run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
"openapi": "generate-spec --verbose && (npm run typescript:generate || echo 'Please manually regenerate the typescript OpenAPI models')",
2424
"rector:check": "rector --dry-run",
2525
"rector:fix": "rector",
26-
"psalm": "psalm --threads=1",
27-
"psalm:dev": "psalm --no-cache --threads=$(nproc)",
26+
"psalm": "psalm --no-cache --threads=$(nproc)",
27+
"psalm:dev": "@psalm",
2828
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
29-
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
30-
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
3129
"post-install-cmd": [
3230
"@composer bin all install --ansi",
3331
"\"vendor/bin/mozart\" compose",
3432
"composer dump-autoload"
3533
],
3634
"post-update-cmd": [
35+
"@composer bin all install --ansi",
3736
"\"vendor/bin/mozart\" compose",
3837
"composer dump-autoload"
3938
],

lib/Controller/RecordingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function validateBackendRequest(string $data): bool {
157157
* @return string
158158
*/
159159
protected function getInputStream(): string {
160-
return file_get_contents('php://input');
160+
return (string)file_get_contents('php://input');
161161
}
162162

163163
/**

lib/Controller/SignalingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ private function validateBackendRequest(string $data): bool {
632632
* @return string
633633
*/
634634
protected function getInputStream(): string {
635-
return file_get_contents('php://input');
635+
return (string)file_get_contents('php://input');
636636
}
637637

638638
/**

psalm.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,6 @@
6767
<referencedClass name="OCA\FederatedFileSharing\AddressHandler" />
6868
</errorLevel>
6969
</UndefinedDocblockClass>
70-
<UndefinedInterfaceMethod>
71-
<errorLevel type="suppress">
72-
<referencedMethod name="OCP\IDBConnection::getInner" />
73-
</errorLevel>
74-
</UndefinedInterfaceMethod>
75-
<InvalidThrow>
76-
<errorLevel type="suppress">
77-
<referencedClass name="Doctrine\DBAL\Exception\UniqueConstraintViolationException" />
78-
</errorLevel>
79-
</InvalidThrow>
80-
<UnimplementedInterfaceMethod>
81-
<errorLevel type="suppress">
82-
<file name="lib/Chat/CommentsManager.php" />
83-
</errorLevel>
84-
</UnimplementedInterfaceMethod>
8570
</issueHandlers>
8671
<stubs>
8772
<file name="tests/stubs/oc_comments_comment.php" />

tests/psalm-baseline.xml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
2+
<files psalm-version="6.2.0@814dfde37b43a1fe6d9b0996e08b19661af53bc5">
33
<file src="lib/AppInfo/Application.php">
44
<UndefinedClass>
55
<code><![CDATA[BeforeTemplateRenderedEvent]]></code>
@@ -44,6 +44,26 @@
4444
<code><![CDATA[$return['num_rooms']]]></code>
4545
</InvalidArrayAccess>
4646
</file>
47+
<file src="lib/Model/Poll.php">
48+
<LessSpecificReturnStatement>
49+
<code><![CDATA[[
50+
'id' => $this->getId(),
51+
// The room id is not needed on the API level but only internally for optimising database queries
52+
// 'roomId' => $this->getRoomId(),
53+
'question' => $this->getQuestion(),
54+
'options' => json_decode($this->getOptions(), true, 512, JSON_THROW_ON_ERROR),
55+
'actorType' => $this->getActorType(),
56+
'actorId' => $this->getActorId(),
57+
'actorDisplayName' => $this->getDisplayName(),
58+
'status' => $this->getStatus(),
59+
'resultMode' => $this->getResultMode(),
60+
'maxVotes' => $this->getMaxVotes(),
61+
]]]></code>
62+
</LessSpecificReturnStatement>
63+
<MoreSpecificReturnType>
64+
<code><![CDATA[TalkPollDraft]]></code>
65+
</MoreSpecificReturnType>
66+
</file>
4767
<file src="lib/Notification/Notifier.php">
4868
<InvalidPropertyAssignmentValue>
4969
<code><![CDATA[$this->participants]]></code>
@@ -69,6 +89,30 @@
6989
<code><![CDATA[Filesystem]]></code>
7090
</UndefinedClass>
7191
</file>
92+
<file src="lib/Service/BotService.php">
93+
<InvalidArgument>
94+
<code><![CDATA[[
95+
'type' => 'Activity',
96+
'actor' => [
97+
'type' => 'Person',
98+
'id' => $message->getActorType() . '/' . $message->getActorId(),
99+
'name' => $message->getActorDisplayName(),
100+
],
101+
'object' => [
102+
'type' => 'Note',
103+
'id' => $event->getComment()->getId(),
104+
'name' => $message->getMessageRaw(),
105+
'content' => json_encode($messageData),
106+
'mediaType' => 'text/markdown',
107+
],
108+
'target' => [
109+
'type' => 'Collection',
110+
'id' => $event->getRoom()->getToken(),
111+
'name' => $event->getRoom()->getName(),
112+
]
113+
]]]></code>
114+
</InvalidArgument>
115+
</file>
72116
<file src="lib/Service/RecordingService.php">
73117
<LessSpecificReturnStatement>
74118
<code><![CDATA[$recordingFolder]]></code>

vendor-bin/psalm/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"config": {
33
"platform": {
4-
"php": "8.1"
4+
"php": "8.1.17"
55
},
66
"sort-packages": true
77
},
88
"require-dev": {
9-
"vimeo/psalm": "^5.26.0"
9+
"vimeo/psalm": "^6.2.0"
1010
}
1111
}

0 commit comments

Comments
 (0)