Skip to content

chore(psalm): reduce baseline noise — suppress + stubs + redundant casts (#122)#133

Merged
Jaggob merged 1 commit into
mainfrom
chore/122-psalm-burndown
Jun 8, 2026
Merged

chore(psalm): reduce baseline noise — suppress + stubs + redundant casts (#122)#133
Jaggob merged 1 commit into
mainfrom
chore/122-psalm-burndown

Conversation

@Jaggob

@Jaggob Jaggob commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Part 1 of the Psalm baseline burn-down (#122). Clears the trivial / OCP-resolution-artifact findings so the baseline reflects only real type issues — from 131 → 34.

Changes

  • MissingOverrideAttribute (33) → suppressed project-wide. #[\Override] is PHP 8.3+, but the app supports PHP 8.1+ (info.xml), so requiring it isn't appropriate.
  • OCP-resolution artifacts (36) → resolved.
    • tests/psalm/missing-class-stubs.php defines the two unshipped OC\ internals (OC\Hooks\Emitter, OC\User\NoUserException) that nextcloud/ocp's OCP\Files\IRootFolder references. With those present the real OCP type files load, so Psalm gets the actual API (not UndefinedClass).
    • Targeted <referencedClass> suppressions for genuinely-external classes that aren't in nextcloud/ocp and can't be cleanly stubbed: Doctrine\DBAL\Schema\Table, \OC, OC\Security\CSRF\CsrfTokenManager, the Files/Files_Sharing/Viewer events, and OCP\Image (its concrete internal base would need all 25 IImage methods).
  • RedundantCast (31) → removed across 11 services (casts on parse_url() / preg_match() results Psalm already types). Behaviour-neutral — careful not to touch the non-redundant (string)/(int) coercions on mixed (e.g. AdminSettingsValidator::normalizeHostUrl).

Verification

  • PHPUnit 409 green (cast removals broke nothing), Psalm green (baseline now 34).
  • Full Playwright 23 passed, 0 flaky on NC 33 (CSP, external-pad import, pad open all exercise the touched URL-parsing paths).

Follow-up (part 2)

The remaining 34 baseline entries are the real type issues (TypeDoesNotContainType, InvalidReturnStatement/Type, MismatchingDocblockParamType, MissingTemplateParam, …) — fixed in a separate PR, along with enabling findUnusedCode.

Part of #122.

… casts) (#122)

Part 1 of the Psalm baseline burn-down (#122): clear the trivial/artifact
findings so the baseline reflects only real type issues (131 -> 34).

- Suppress MissingOverrideAttribute project-wide (33): the #[\Override]
  attribute is PHP 8.3+, but the app supports PHP 8.1+ (info.xml).
- Resolve the OCP-resolution artifacts (36):
  - tests/psalm/missing-class-stubs.php defines the two unshipped OC    internals (OC\Hooks\Emitter, OC\User\NoUserException) that nextcloud/ocp's
    OCP\Files\IRootFolder references, so the real OCP type files load and Psalm
    gets their actual API instead of UndefinedClass.
  - Targeted <referencedClass> suppressions for genuinely-external classes not
    in nextcloud/ocp and not cleanly stubbable (Doctrine\DBAL\Schema\Table,
    \OC, OC\Security\CSRF\CsrfTokenManager, the Files/Files_Sharing/Viewer
    events, and OCP\Image whose concrete internal base needs 25 IImage methods).
- Remove 31 RedundantCasts (casts on parse_url()/preg_match() results Psalm
  already types) across 11 services — behaviour-neutral.

PHPUnit 409 + Psalm green (baseline now 34 real type issues, tackled in the
follow-up); full Playwright 23/23 on NC 33.

Part of #122.
@Jaggob Jaggob merged commit b8f3544 into main Jun 8, 2026
13 checks passed
Jaggob added a commit that referenced this pull request Jun 9, 2026
Bump version to 1.1.0-alpha.3 across appinfo/info.xml, package.json, and
package-lock.json (consistency guard green); regenerate js/ license
sidecars with the new version (bundles unchanged). Add the alpha.3
CHANGELOG section summarising the security hardening (#105, #102, #110),
the Playwright e2e suite (#54), the Psalm burndown + findUnusedCode
(#82, #122, #133, #134), and the supporting refactors/tooling.
@Jaggob Jaggob deleted the chore/122-psalm-burndown branch June 17, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant