Skip to content

Make the two session accessors return what they hold - #720

Merged
blaipr merged 1 commit into
mainfrom
fix/session-accessor-types
Aug 13, 2026
Merged

Make the two session accessors return what they hold#720
blaipr merged 1 commit into
mainfrom
fix/session-accessor-types

Conversation

@blaipr

@blaipr blaipr commented Aug 13, 2026

Copy link
Copy Markdown
Member

The bug

Two dormant type mismatches in Session, both found while covering it:

  • getAccountColor(): string returned whatever setAccountColor(array $color) had stored — always an array. The first read after a legitimate write would have raised a TypeError on the way out. SessionContext declared the same mismatch.
  • getTheme(): string had no default on its read, so a session that had not been given a theme returned null from a method declared to return a string.

Neither is called anywhere in src/ today, which is the only reason it went unnoticed — and exactly why it was worth fixing before somebody used one.

The fix

Both now return what they always held: an array of colours keyed by account id, and a string that is empty before a theme is chosen.

Testing

A round trip for each, including what a session that has never been given either returns — which is where both used to raise.

Doc, folded in

  • Coverage is now 96.6% (21648/22402).
  • The pcov note gains the thing that made a file look like a gap when it is at 100%: the two suites disagree about which lines are statements in nine files out of 995 (31 statements; Application/Account/Services/AccountSearch.php worst, 48 vs 61). A merge that treats absent from one report as uncovered overstates them, so a per-file gap is worth confirming with a focused run before anyone is sent to fix it.

getAccountColor() was declared to return a string and returned whatever
setAccountColor(array) had stored — always an array — so the first read after a
legitimate write would have raised a TypeError on the way out. The interface
carried the same mismatch. Nothing in the application calls it, which is the
only reason it went unnoticed.

getTheme() had the same shape of problem from the other side: no default, so a
session that had not been given a theme returned null from a method declared to
return a string.

Both are now what they always held: an array of colours keyed by account id, and
a string that is empty before a theme is chosen.

Doc: the coverage figure is now 96.6% (21648/22402), and the pcov note gains the
thing that made a file look like a gap when it is at 100% — the two suites
disagree about which lines are statements in nine files, so a merged report
overstates them. Confirm per-file before sending anyone to fix one.
@blaipr
blaipr merged commit af8c2b6 into main Aug 13, 2026
8 checks passed
@blaipr
blaipr deleted the fix/session-accessor-types branch August 13, 2026 18:19
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