Skip to content

Commit

Permalink
Merge pull request #14286 from nextcloud/ci/noid/psalm6
Browse files Browse the repository at this point in the history
ci: Update psalm to v6
  • Loading branch information
nickvergessen authored Feb 6, 2025
2 parents 20bd1c9 + aee336b commit e67e50a
Show file tree
Hide file tree
Showing 8 changed files with 1,459 additions and 307 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,49 @@ concurrency:
group: psalm-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
static-analysis:
runs-on: ubuntu-latest

name: static-psalm-analysis
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

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

- name: Check enforcement of minimum PHP version ${{ steps.versions.outputs.php-min }} in psalm.xml
run: grep 'phpVersion="${{ steps.versions.outputs.php-min }}' psalm.xml

- name: Set up php${{ steps.versions.outputs.php-available }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: ${{ steps.versions.outputs.php-available }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
ini-file: development
# Temporary workaround for missing pcntl_* in PHP 8.3
ini-values: disable_functions=
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: composer i
run: |
composer remove nextcloud/ocp --dev
composer i
- name: Check for vulnerable PHP dependencies
run: composer require --dev roave/security-advisories:dev-latest

- name: Install nextcloud/ocp
run: composer require --dev nextcloud/ocp:dev-${{ steps.versions.outputs.branches-max }} --ignore-platform-reqs --with-dependencies

- name: Run coding standards check
run: composer run psalm
run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
"openapi": "generate-spec --verbose && (npm run typescript:generate || echo 'Please manually regenerate the typescript OpenAPI models')",
"rector:check": "rector --dry-run",
"rector:fix": "rector",
"psalm": "psalm --threads=1",
"psalm:dev": "psalm --no-cache --threads=$(nproc)",
"psalm": "psalm --no-cache --threads=$(nproc)",
"psalm:dev": "@psalm",
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"post-install-cmd": [
"@composer bin all install --ansi",
"\"vendor/bin/mozart\" compose",
"composer dump-autoload"
],
"post-update-cmd": [
"@composer bin all install --ansi",
"\"vendor/bin/mozart\" compose",
"composer dump-autoload"
],
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/RecordingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private function validateBackendRequest(string $data): bool {
* @return string
*/
protected function getInputStream(): string {
return file_get_contents('php://input');
return (string)file_get_contents('php://input');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private function validateBackendRequest(string $data): bool {
* @return string
*/
protected function getInputStream(): string {
return file_get_contents('php://input');
return (string)file_get_contents('php://input');
}

/**
Expand Down
15 changes: 0 additions & 15 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,6 @@
<referencedClass name="OCA\FederatedFileSharing\AddressHandler" />
</errorLevel>
</UndefinedDocblockClass>
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<referencedMethod name="OCP\IDBConnection::getInner" />
</errorLevel>
</UndefinedInterfaceMethod>
<InvalidThrow>
<errorLevel type="suppress">
<referencedClass name="Doctrine\DBAL\Exception\UniqueConstraintViolationException" />
</errorLevel>
</InvalidThrow>
<UnimplementedInterfaceMethod>
<errorLevel type="suppress">
<file name="lib/Chat/CommentsManager.php" />
</errorLevel>
</UnimplementedInterfaceMethod>
</issueHandlers>
<stubs>
<file name="tests/stubs/oc_comments_comment.php" />
Expand Down
46 changes: 45 additions & 1 deletion tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<files psalm-version="6.2.0@814dfde37b43a1fe6d9b0996e08b19661af53bc5">
<file src="lib/AppInfo/Application.php">
<UndefinedClass>
<code><![CDATA[BeforeTemplateRenderedEvent]]></code>
Expand Down Expand Up @@ -44,6 +44,26 @@
<code><![CDATA[$return['num_rooms']]]></code>
</InvalidArrayAccess>
</file>
<file src="lib/Model/Poll.php">
<LessSpecificReturnStatement>
<code><![CDATA[[
'id' => $this->getId(),
// The room id is not needed on the API level but only internally for optimising database queries
// 'roomId' => $this->getRoomId(),
'question' => $this->getQuestion(),
'options' => json_decode($this->getOptions(), true, 512, JSON_THROW_ON_ERROR),
'actorType' => $this->getActorType(),
'actorId' => $this->getActorId(),
'actorDisplayName' => $this->getDisplayName(),
'status' => $this->getStatus(),
'resultMode' => $this->getResultMode(),
'maxVotes' => $this->getMaxVotes(),
]]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[TalkPollDraft]]></code>
</MoreSpecificReturnType>
</file>
<file src="lib/Notification/Notifier.php">
<InvalidPropertyAssignmentValue>
<code><![CDATA[$this->participants]]></code>
Expand All @@ -69,6 +89,30 @@
<code><![CDATA[Filesystem]]></code>
</UndefinedClass>
</file>
<file src="lib/Service/BotService.php">
<InvalidArgument>
<code><![CDATA[[
'type' => 'Activity',
'actor' => [
'type' => 'Person',
'id' => $message->getActorType() . '/' . $message->getActorId(),
'name' => $message->getActorDisplayName(),
],
'object' => [
'type' => 'Note',
'id' => $event->getComment()->getId(),
'name' => $message->getMessageRaw(),
'content' => json_encode($messageData),
'mediaType' => 'text/markdown',
],
'target' => [
'type' => 'Collection',
'id' => $event->getRoom()->getToken(),
'name' => $event->getRoom()->getName(),
]
]]]></code>
</InvalidArgument>
</file>
<file src="lib/Service/RecordingService.php">
<LessSpecificReturnStatement>
<code><![CDATA[$recordingFolder]]></code>
Expand Down
4 changes: 2 additions & 2 deletions vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"config": {
"platform": {
"php": "8.1"
"php": "8.1.17"
},
"sort-packages": true
},
"require-dev": {
"vimeo/psalm": "^5.26.0"
"vimeo/psalm": "^6.2.0"
}
}
Loading

0 comments on commit e67e50a

Please sign in to comment.