chore(psalm): the share listener as Psalm 7.12 reads it, stubs instead of a baseline for Imagick #14

Merged
dawid merged 1 commit from psalm-7.12 into main 2026-11-23 07:15:11 +00:00
Owner

Renovate's #7 (Psalm 7.12) fails standards with three findings. This PR fixes them in the code instead of adding them to the baseline.

  • TypeDoesNotContainType at line 56: method_exists($event, 'getShare') narrows $event to Event&object{getshare()}. Psalm 7.12 then no longer accepts that type as ShareCreatedEvent. handle() now checks instanceof ShareCreatedEvent first, and checks method_exists() only for the other events (Talk's BeforeDuplicateShareSentEvent). The behaviour is unchanged.
  • TypeDoesNotContainType at line 65: class_exists() on a string literal of a class Psalm didn't know. Psalm now loads the existing test stub tests/stubs/files_sharing_events.php, and the listener uses UserShareAccessUpdatedEvent::class and new UserShareAccessUpdatedEvent(...) directly. That also lets Psalm check the constructor. The unused public constant SHARE_ACCESS_UPDATED_EVENT is gone.
  • UnusedBaselineEntry in StickerService: Psalm 7.12 resolves \Imagick through class_exists() but still doesn't know \ImagickPixel or \ImagickException. A Psalm stub tests/stubs/imagick.php covers what StickerService uses, and the baseline's Imagick entries are removed.
  • .forgejo/regenerate.yml: the bot's PHP prepare now installs mbstring, as ci.yml's tools do. Without mbstring, Psalm crashes with mb_strcut() undefined, and the step ignores the exit (|| true), so the bot would never have regenerated the baseline.

Checked in php:8.6-cli-alpine with ci.yml's extensions: Psalm 7.0.5 (main's lock) and 7.12.0 (#7's lock) both report no errors, cs:check finds nothing, and PHPUnit passes (17 tests).

Once this is merged, Renovate rebases #7, which should then pass.

🤖 Generated with Claude Code

Renovate's #7 (Psalm 7.12) fails `standards` with three findings. This PR fixes them in the code instead of adding them to the baseline. - **`TypeDoesNotContainType` at line 56:** `method_exists($event, 'getShare')` narrows `$event` to `Event&object{getshare()}`. Psalm 7.12 then no longer accepts that type as `ShareCreatedEvent`. `handle()` now checks `instanceof ShareCreatedEvent` first, and checks `method_exists()` only for the other events (Talk's `BeforeDuplicateShareSentEvent`). The behaviour is unchanged. - **`TypeDoesNotContainType` at line 65:** `class_exists()` on a string literal of a class Psalm didn't know. Psalm now loads the existing test stub `tests/stubs/files_sharing_events.php`, and the listener uses `UserShareAccessUpdatedEvent::class` and `new UserShareAccessUpdatedEvent(...)` directly. That also lets Psalm check the constructor. The unused public constant `SHARE_ACCESS_UPDATED_EVENT` is gone. - **`UnusedBaselineEntry` in StickerService:** Psalm 7.12 resolves `\Imagick` through `class_exists()` but still doesn't know `\ImagickPixel` or `\ImagickException`. A Psalm stub `tests/stubs/imagick.php` covers what StickerService uses, and the baseline's Imagick entries are removed. - **`.forgejo/regenerate.yml`:** the bot's PHP prepare now installs mbstring, as ci.yml's tools do. Without mbstring, Psalm crashes with `mb_strcut()` undefined, and the step ignores the exit (`|| true`), so the bot would never have regenerated the baseline. Checked in `php:8.6-cli-alpine` with ci.yml's extensions: Psalm 7.0.5 (main's lock) and 7.12.0 (#7's lock) both report no errors, `cs:check` finds nothing, and PHPUnit passes (17 tests). Once this is merged, Renovate rebases #7, which should then pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chore(psalm): the share listener as Psalm 7.12 reads it, stubs instead of a baseline for Imagick
All checks were successful
CI / php (dev-master) (pull_request) Successful in 1m42s
CI / php (dev-stable35) (pull_request) Successful in 1m49s
CI / standards (pull_request) Successful in 1m55s
CI / php (dev-stable33) (pull_request) Successful in 1m58s
CI / php (dev-stable34) (pull_request) Successful in 1m56s
CI / php (dev-stable32) (pull_request) Successful in 1m58s
CI / javascript (pull_request) Successful in 20s
CI / server (32) (pull_request) Successful in 2m38s
CI / server (35) (pull_request) Successful in 2m46s
7c0bfb5b6a
dawid merged commit 561e027140 into main 2026-11-23 07:15:11 +00:00
dawid deleted branch psalm-7.12 2026-11-23 07:15:12 +00:00

Tests of CI / php (dev-master): passed

17 passed, 0 failed, 0 skipped (17 tests, 0.1 s)

Of 7c0bfb5b6a, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-master- --> ### Tests of CI / php (dev-master): passed **17 passed, 0 failed, 0 skipped** (17 tests, 0.1 s) <sub>Of 7c0bfb5b6a, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/111), updated by every run.</sub>

Tests of CI / php (dev-stable34): passed

17 passed, 0 failed, 0 skipped (17 tests, 0.1 s)

Of 7c0bfb5b6a, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable34- --> ### Tests of CI / php (dev-stable34): passed **17 passed, 0 failed, 0 skipped** (17 tests, 0.1 s) <sub>Of 7c0bfb5b6a, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/111), updated by every run.</sub>

Tests of CI / php (dev-stable33): passed

17 passed, 0 failed, 0 skipped (17 tests, 0.1 s)

Of 7c0bfb5b6a, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable33- --> ### Tests of CI / php (dev-stable33): passed **17 passed, 0 failed, 0 skipped** (17 tests, 0.1 s) <sub>Of 7c0bfb5b6a, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/111), updated by every run.</sub>

Tests of CI / php (dev-stable32): passed

17 passed, 0 failed, 0 skipped (17 tests, 0.1 s)

Of 7c0bfb5b6a, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable32- --> ### Tests of CI / php (dev-stable32): passed **17 passed, 0 failed, 0 skipped** (17 tests, 0.1 s) <sub>Of 7c0bfb5b6a, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/111), updated by every run.</sub>

Tests of CI / php (dev-stable35): passed

17 passed, 0 failed, 0 skipped (17 tests, 0.1 s)

Of 7c0bfb5b6a, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable35- --> ### Tests of CI / php (dev-stable35): passed **17 passed, 0 failed, 0 skipped** (17 tests, 0.1 s) <sub>Of 7c0bfb5b6a, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/111), updated by every run.</sub>
Sign in to join this conversation.
No description provided.