Skip to content

feat(view): add the page view model, page context and its listener - #10

Merged
tyrsson merged 3 commits into
1.0.xfrom
tyrsson-render-02-foundation
Nov 13, 2026
Merged

tyrsson merged 3 commits into
1.0.xfrom
tyrsson-render-02-foundation

Conversation

@tyrsson

@tyrsson tyrsson commented Nov 13, 2026

Copy link
Copy Markdown
Member

Phase 2 of specs/001-document-view-render/tasks.md: the foundation types the seam is built
from. Phase 1 (#9) is the base of this branch, and the spec commit from
tyrsson-document-render-speckit is still in the diff until that pull request merges.

Tasks covered

  • T004 src/View/Page.php
  • T005 test/unit/PageTest.php
  • T006 src/View/PageContext.php
  • T007 test/unit/PageContextTest.php
  • T008 src/Container/PageContextFactory.php
  • T009 test/unit/PageContextFactoryTest.php
  • T010 src/View/PageContextListener.php
  • T011 test/unit/PageContextListenerTest.php
  • T012 src/Container/PageContextListenerFactory.php
  • T013 test/unit/PageContextListenerFactoryTest.php
  • T014 src/ConfigProvider.php

Gates

Run once for this push:

  • mago format --check: all files already formatted
  • mago lint: no issues found
  • mago analyze: no issues found
  • mago guard: no issues found
  • PHPUnit: 79 tests, 133 assertions, all passing (unit and integration)

No baseline entry was added.

Decisions the plan did not settle

  1. Two @mago-expect comments are on Page, for lint:too-many-methods and
    lint:excessive-parameter-list. Both limits are structural: ModelInterface plus Countable and
    IteratorAggregate require all fourteen methods, and the data model fixes eleven fields. The
    fleet already carries the same suppression form in webware-console and webware-event.
    Suppressing needed approval under the mago workflow; flagging it here.
  2. Argument order in the Page constructor is alphabetical within the required group and again
    within the optional group, because PHP will not accept a required parameter after an optional
    one. The data model asks for alphabetical order by field name without saying how to reconcile
    that with the language rule.
  3. Page::getVariables() is annotated array<non-empty-string, mixed>, not array<string, mixed>,
    because ModelInterface::getVariables() declares the narrower key type and the analyzer rejects
    the wider one.
  4. T011 asks for createStub() event and page doubles. DocumentPreRenderEvent and Page are
    both final, so PHPUnit cannot double either; the tests build real ones, which covers the same
    behaviour. T013's stub container is used as written.
  5. Page::setCaptureTo() and setTerminal() take $capture and $terminate to match the names
    in ModelInterface, rather than $captureTo and $terminal as the contract table spells them.

Not in scope, left untouched

LayoutWrappingMiddleware, its factory and their registrations are deleted in T023, in phase 3.

tyrsson and others added 3 commits November 12, 2026 19:23
…straint

The document view seam imports Mezzio\Template\TemplateRendererInterface directly, so the package that provides it becomes a direct requirement instead of an accident of webware-theme's tree. The php constraint now covers 8.6 while config.platform.php stays pinned at 8.4.99.

Baseline gates recorded before any code change: mago format --check, lint, analyze and guard exit zero, 43 unit tests and 8 integration tests pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
Page implements Laminas\View\Model\ModelInterface for the state a template
reads, never for a position in the render tree: it is final readonly and every
mutator throws, because LaminasViewRenderer writes to the model it renders and
walks children through beforeRender().

PageContext holds the current page for one conversion. PageContextListener
copies it into the document data under commondoc.page on
DocumentPreRenderEvent, so the renderer reads the page from the document it
belongs to and a document built outside a build simply has no entry.

Both factories are registered in ConfigProvider, and the aliases docblock now
says interface-string because its only key is an interface.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
Page implements ModelInterface and returns an ArrayIterator, so the
IteratorAggregate import was never referenced. Mago reports it as
no-redundant-use on both supported PHP versions, which fails the lint gate
and skips the suites behind it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tyrsson
tyrsson merged commit 1fde163 into 1.0.x Nov 13, 2026
12 checks passed
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