Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Clear PHPStan noise + align phpunit config + walkthrough screenshots#41

Merged
rubenvdlinde merged 1 commit into
chore/polish-and-walkthrough-2026-04-29from
chore/phpstan-phpunit-screenshots
Apr 30, 2026
Merged

Clear PHPStan noise + align phpunit config + walkthrough screenshots#41
rubenvdlinde merged 1 commit into
chore/polish-and-walkthrough-2026-04-29from
chore/phpstan-phpunit-screenshots

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Summary

Three quality / docs items left over after PR #39's walkthrough that were out of scope at the time but worth having before more code lands.

PHPStan: 722 → 0

PR #39 documented 719 unknown OCP* errors as an environmental issue. The actual cause: nextcloud/ocp ships PHP stubs but declares no autoload section, so neither composer nor PHPStan could resolve any Nextcloud type. Every IUser, IL10N, IURLGenerator, IConfig call was reported as a missing class.

  • composer.json gains an autoload-dev block mapping OCP\\vendor/nextcloud/ocp/OCP/ and NCU\\vendor/nextcloud/ocp/NCU/. Now composer dump-autoload registers the stubs and PHPStan resolves them.
  • phpstan.neon: scanDirectories narrowed to the actual subdirectories. ignoreErrors adds focused entries for Doctrine\DBAL\Schema\Table (provided by Nextcloud's 3rdparty bundle, not our app's vendor/ — exercised at runtime), the JSONResponse strict-status union (caller widens via Http::STATUS_* defaults at the public boundary), and Entity::jsonSerialize() (concrete subclasses implement JsonSerializable; the stub doesn't).

Real type bugs PHPStan caught once it could see Nextcloud

  • AdminSettingMapper::setSetting() passed a DateTime instance to setUpdatedAt(?string). Now passes (new DateTime())->format('c') like the rest of the codebase.
  • setIsActive(true) in DashboardResolver, DashboardService, TemplateServicesetIsActive(1) (int column).
  • setIsDefault($isDefault) (bool) in AdminTemplateServicesetIsDefault((int) $isDefault) (SMALLINT column).
  • getIsVisible() === false / getIsCompulsory() === false (int columns) → === 0 in ConditionalService and PermissionService.
  • DashboardResolver::getEffectivePermissionLevel() — removed the unreachable null-fallback branch (Dashboard::permissionLevel is non-nullable with PERMISSION_FULL default) plus the now-unused settingMapper / AdminSetting imports that only existed for it.

Same coercion semantics at runtime — PHPStan can now verify them.

phpunit-unit.xml rename

git mv phpunit.xml -> phpunit-unit.xml to align with the convention other Conduction apps use. Composer scripts (test:unit, test:all, test:coverage, test) now pass --configuration phpunit-unit.xml explicitly so PHPUnit no longer relies on auto-discovery.

Screenshots

Captured at 1440×1100 for docs/screenshots/:

  • admin-settings.png — full admin page with default settings + empty templates section
  • customize-panel-widgets.png — Widgets tab of the customize sidebar
  • customize-panel-dashboards.png — Dashboards tab with three test dashboards (My Dashboard, Walkthrough, Screenshot Demo active)
  • template-create-modal.png — admin template creation modal with all fields visible

The seeded-tiles screenshot lives on PR #40 (feat/seed-tiles-on-new-dashboard) since that's the branch that introduces the seeding behaviour.

Test plan

  • composer phpcs — clean
  • composer phpmd — clean
  • composer psalm — 0 errors
  • composer phpstan0 errors (down from 722)
  • phpunit --configuration phpunit-unit.xml — 106/106 passing, 293 assertions

Notes

…creenshots

PHPStan
-------
- Add autoload-dev mapping for nextcloud/ocp's OCP\* and NCU\* namespaces.
  The package ships PHP stubs but declares no autoload section, so PHPStan
  could not resolve any Nextcloud type and reported every OCP\IUser /
  IL10N / IURLGenerator etc. call as "unknown class" - 722 errors total.
  Registering the namespace in our autoload-dev makes the stubs reachable.
- Tighten phpstan.neon scanDirectories to point at the OCP/ and NCU/
  subdirectories (not the package root) and add focused ignoreErrors for
  Doctrine\DBAL\Schema\Table calls (provided by Nextcloud's 3rdparty
  bundle, not our app's vendor) and the JSONResponse strict-status union
  / Entity::jsonSerialize stub gaps.
- Result: 722 -> 0 errors. PHPStan is now meaningful CI signal.

Real type fixes surfaced once OCP became visible
------------------------------------------------
- AdminSettingMapper::setSetting(): pass formatted ISO string to
  setUpdatedAt() instead of a DateTime instance (the entity stores the
  timestamp as ?string).
- DashboardResolver, DashboardService, TemplateService: use 1 instead of
  true for setIsActive(int), and 0 instead of false for the
  getIsCompulsory()/getIsVisible() comparisons. Same coercion semantics
  at runtime, but PHPStan can verify the types.
- AdminTemplateService::createTemplate(): cast bool $isDefault to int
  before passing to the SMALLINT column setter.
- DashboardResolver::getEffectivePermissionLevel(): drop the unreachable
  null-fallback branch (Dashboard::permissionLevel is non-nullable with
  PERMISSION_FULL default) and the unused settingMapper / AdminSetting
  imports that only existed to feed it.
- ConditionalService / PermissionService: switch
  getIsVisible()/getIsCompulsory() === false to === 0 (the Entity stores
  these as int flags, not booleans).

phpunit-unit.xml rename
-----------------------
- git mv phpunit.xml -> phpunit-unit.xml to match the convention used
  across other Conduction apps. Composer scripts (test:unit, test:all,
  test:coverage, test) updated to pass --configuration explicitly so
  PHPUnit no longer needs to auto-discover.

Screenshots
-----------
- Add docs/screenshots/admin-settings.png, customize-panel-widgets.png,
  customize-panel-dashboards.png, template-create-modal.png to document
  the main customize / admin / template flows. Captured at 1440x1100.

Tests: 106 / 106 passing, 293 assertions.
PHPCS / PHPMD / Psalm / PHPStan: all clean.
@rubenvdlinde
rubenvdlinde merged commit 2f76611 into chore/polish-and-walkthrough-2026-04-29 Apr 30, 2026
1 check passed
@rubenvdlinde
rubenvdlinde deleted the chore/phpstan-phpunit-screenshots branch April 30, 2026 20:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant