-
Notifications
You must be signed in to change notification settings - Fork 23
Ci/phpstan #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Ci/phpstan #695
Changes from all commits
f3a2c46
b36ff3f
eba5e28
120b082
3bf6e9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # This workflow is provided via the organization template repository | ||
| # | ||
| # https://github.com/nextcloud/.github | ||
| # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization | ||
| # | ||
| # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| name: PHPStan | ||
|
|
||
| on: pull_request | ||
|
|
||
| concurrency: | ||
| group: phpstan-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| phpstan-static-analysis: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| name: static-phpstan-analysis | ||
| steps: | ||
| - name: Checkout | ||
| 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: 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 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Install dependencies | ||
| run: composer i | ||
|
|
||
| - name: Run static analysis | ||
| run: composer run phpstan |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,10 +86,10 @@ public function getRetentions(): DataResponse { | |
| * Create a retention rule | ||
| * | ||
| * @param int $tagid Tag the retention is based on | ||
| * @param 0|1|2|3 $timeunit Time unit of the retention (days, weeks, months, years) | ||
| * @param int<0, 3> $timeunit Time unit of the retention (days, weeks, months, years) | ||
| * @psalm-param Constants::UNIT_* $timeunit | ||
| * @param positive-int $timeamount Amount of time units that have to be passed | ||
| * @param 0|1 $timeafter Whether retention time is based creation time (0) or modification time (1) | ||
| * @param int<1, 32000> $timeamount Amount of time units that have to be passed | ||
| * @param int<0, 1> $timeafter Whether retention time is based creation time (0) or modification time (1) | ||
| * @psalm-param Constants::MODE_* $timeafter | ||
| * @return DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'tagid'|'timeunit'|'timeamount'|'timeafter'}, array{}>|DataResponse<Http::STATUS_CREATED, Files_RetentionRule, array{}> | ||
| * | ||
|
|
@@ -103,16 +103,6 @@ public function addRetention(int $tagid, int $timeunit, int $timeamount, int $ti | |
| return new DataResponse(['error' => 'tagid'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| if ($timeunit < 0 || $timeunit > 3) { | ||
| return new DataResponse(['error' => 'timeunit'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
| if ($timeamount < 1 || $timeamount > 32_000) { | ||
| return new DataResponse(['error' => 'timeamount'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
| if ($timeafter < 0 || $timeafter > 1) { | ||
| return new DataResponse(['error' => 'timeafter'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| // Fetch tag_id | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('tag_id') | ||
|
|
@@ -154,7 +144,7 @@ public function addRetention(int $tagid, int $timeunit, int $timeamount, int $ti | |
| * Delete a retention rule | ||
| * | ||
| * @param int $id Retention rule to delete | ||
| * @return DataResponse<Http::STATUS_NO_CONTENT|Http::STATUS_NOT_FOUND, list<empty>, array{}> | ||
| * @return DataResponse<Http::STATUS_NO_CONTENT|Http::STATUS_NOT_FOUND, array{}, array{}> | ||
|
Comment on lines
-157
to
+147
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should stay |
||
| * | ||
| * 204: Retention rule deleted | ||
| * 404: Retention rule not found | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
| parameters: | ||
| level: 5 | ||
| paths: | ||
| - lib | ||
| scanFiles: | ||
| - tests/stub.phpstub | ||
| scanDirectories: | ||
| - vendor/nextcloud/ocp | ||
| ignoreErrors: | ||
| - '#on an unknown class Doctrine\\DBAL\\Schema\\Table#' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,7 @@ public function testAddRetentionInvalidTag(): void { | |
| } | ||
|
|
||
| public function testAddRetentionInvalidTimeUnit(): void { | ||
| $this->markTestSkipped('Test is no longer applicable as the Dispatcher is limiting values'); | ||
| $response = $this->api->addRetention(42, -1, 1); | ||
| $this->assertSame(Http::STATUS_BAD_REQUEST, $response->getStatus()); | ||
|
|
||
|
|
@@ -75,6 +76,7 @@ public function testAddRetentionInvalidTimeUnit(): void { | |
| } | ||
|
|
||
| public function testAddRetentionInvalidTimeAmount(): void { | ||
| $this->markTestSkipped('Test is no longer applicable as the Dispatcher is limiting values'); | ||
| $response = $this->api->addRetention(42, 3, 128_000); | ||
| $this->assertSame(Http::STATUS_BAD_REQUEST, $response->getStatus()); | ||
| } | ||
|
Comment on lines
69
to
82
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can be removed now, right? |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "config": { | ||
| "platform": { | ||
| "php": "8.1" | ||
| } | ||
| }, | ||
| "require-dev": { | ||
| "phpstan/phpstan": "^2.1.0" | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so happy about converting enums to ranges :/ This makes the specifications worse and clients that generate code from it, too.