Skip to content

Fix the real phpstan findings, shrink the baseline - #327

Merged
codeling merged 2 commits into
mainfrom
ccr-204a24a7-61t8iy
Nov 20, 2026
Merged

codeling merged 2 commits into
mainfrom
ccr-204a24a7-61t8iy

Conversation

@codeling

Copy link
Copy Markdown
Owner

What

Went through the findings listed in phpstan-baseline.neon (phpstan level 5 against Joomla 6.2.0), fixed the ones that point at real defects and removed their entries (66 → 53 findings, 50 entries).

Fixed

  • DisplayController::display() (admin and site): returns what it should (also on the early return), and $urlparams defaults to [] like Joomla's BaseController, not false
  • HtblockController::cancel(): returns true, as FormController::cancel()
  • HtblockModel::getItem(): returns an object, as AdminModel::getItem() (nothing reads the array)
  • Settings toolbar: no false as $formId of ToolbarHelper::custom()
  • DnsHelper::readName(): $next documented as int|null (3 findings)
  • LoggerHelper: dropped the never read property $maxBytes

Left in the baseline (not relevant)

  • Joomla's imprecise types: getModel() returning bool|BaseDatabaseModel (controllers and views), CMSApplicationInterface without getUserState(), getDocument(), getClientId(), setHeader(), allowCache(), getMessageQueue($clear)
  • getForm() returning false on failure (what Joomla's core models do, although FormModelInterface documents Form)
  • FormRule::test() returning an UnexpectedValueException (Joomla's way to carry the message, documented as bool)
  • QueryInterface::returning(): only called for PostgreSQL
  • is_array() of apache_request_headers(): a defensive check

Test plan

  • phpstan analyse passes with the new baseline
  • php -l of the changed files
  • CI (integration tests)

Generated by Claude Code

- DisplayController (admin and site): return what display() returns
  (also on the early return) and default $urlparams to [] like Joomla's
  BaseController, instead of false
- HtblockController::cancel() returns true, as FormController::cancel()
- HtblockModel::getItem() returns an object, as AdminModel::getItem()
- Settings toolbar: no formId false for ToolbarHelper::custom()
- DnsHelper::readName(): document $next as int|null
- LoggerHelper: drop the never read property $maxBytes

13 entries of phpstan-baseline.neon go away; what is left are the
imprecise types of Joomla's own API (getModel() returning bool|Model,
CMSApplicationInterface without getUserState() etc., FormRule::test()
documented as bool) and two defensive checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMQAPCNVx27UwnZRmTY
entry() reads the clock, so the pruning tests that built the "new" entry
again for the comparison failed whenever a second boundary fell between the
two calls (seen in CI: ...:22 vs ...:23).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMQAPCNVx27UwnZRmTY
@codeling
codeling merged commit 05fb017 into main Nov 20, 2026
20 checks passed
@codeling
codeling deleted the ccr-204a24a7-61t8iy branch November 20, 2026 22:31
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.

2 participants