Skip to content

refactor(support): share the stored row-list reading between the approval gates, routing, the flow projection, subsidies and the case journal - #5895

Merged
rubenvdlinde merged 4 commits into
developmentfrom
quality/h16-row-list-all
Nov 12, 2026
Merged

rubenvdlinde merged 4 commits into
developmentfrom
quality/h16-row-list-all

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Six classes read a stored list of rows the same way: decode a JSON string first, answer an empty list for anything that is then not an array, and keep the entries that are rows, in order and re-indexed.

Class Method
Service\CaseType\ApprovalGateDeclaration rowsOf() (private static)
Controller\RoutingController decodeSteps()
Service\Support\ProjectsOntoFlows (trait) decodeList()
Service\Subsidie\SubsidieService rowsOf()
Service\CaseLifecycleService readJournal(), after turning a value that is not an array into a string
Service\Lifecycle\CaseJournal entries() (public), the same

That reading is now one static helper, Service\Support\RowList::from() (split in two units so each stays small). Each copy keeps its name and visibility and delegates, so no caller changes; RoutingController::reroute() (#5340) is not touched. The copies were spelled three ways (three decode into a temporary in two different shapes, one decodes in place); all answer the same, as the tests below pin, and the helper uses the shortest spelling. The two journal readers keep their own conversion of a non-array value to a string (so an object value still fails as before) and hand the rest to the helper.

This replaces #5894 so that the two journal readers join the same change: a second PR adding the same helper would be reported by the duplicated-fragment gate against the copies this one removes.

Other methods (LhsRecommendationService::indexCells(), AdmissibilityJudgement::declarationFor(), StatusChecklist::itemsFor(), RemedyClauseDeclaration::declarationFor()) start with the same JSON decoding but go on to read something else, so they are not copies of this reading and are left alone.

Characterisation tests

  • tests/Unit/Service/Support/RowListCopiesTest.php, committed first and green on the old code: every copy (by reflection; the trait through a migrator that composes it) against ten stored values: a JSON list and object with non-row entries, a JSON scalar, invalid JSON, an empty string, an array with keys and non-row entries (re-indexed), an empty array, null, an integer and an object. 40 cases.
  • tests/Unit/Service/Lifecycle/CaseJournalReadingCopiesTest.php, committed before its change and green on the old code: both journal readers against seven stored journals, and that an object journal still fails the string conversion. 16 cases.

What ran

  • phpunit -c phpunit-unit.xml on both new tests, every unit test class that names one of the six classes or the two flow migrators, and tests/Unit/Architecture: 389 tests, all green but one inherited failure.
  • phpcs and phpstan analyse on the touched files: no findings.
  • The duplicated-fragment and unit ratchet (gate 122) against development: 0 findings.

Inherited: ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSite is red on development too (a stale allowlist entry for lib/Service/Settings/OpenRegisterBridge.php).

Duplication figures (duplicated 6-line windows, before -> after)

  • RoutingController <-> ApprovalGateDeclaration: 12 -> 0
  • ProjectsOntoFlows <-> SubsidieService: 6 -> 0
  • CaseLifecycleService <-> CaseJournal: 9 -> 0

Found after opening, from a full phpmd run: with this change RoutingController reaches a coupling between objects of 13, one over the rule's limit (CouplingBetweenObjects, under 13). RowList is the extra dependency. On development the class is under the limit. This needs a reviewer's call: accept the finding, or take one other dependency out of the class in a follow-up.

AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.


Generated by Claude Code

… routing, flow projection and subsidies

Assisted-by: ClaudeCode:claude-opus-5-5
…oval gates, routing, the flow projection and subsidies

ApprovalGateDeclaration::rowsOf(), RoutingController::decodeSteps(),
ProjectsOntoFlows::decodeList() and SubsidieService::rowsOf() read a
stored list the same way: decode a JSON string, answer an empty list for
anything not an array, keep the array rows in order. That reading is now
Support\RowList::from(); each copy keeps its name and delegates.

Assisted-by: ClaudeCode:claude-opus-5-5
… the case journal before sharing it

Assisted-by: ClaudeCode:claude-opus-5-5
…t reading

CaseLifecycleService::readJournal() and CaseJournal::entries() read the
activity journal the same way as the other stored row lists, after
turning a value that is not an array into a string. Both now do that
conversion and hand the rest to Support\RowList::from().

Assisted-by: ClaudeCode:claude-opus-5-5
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