Skip to content

12C: Hand every pass the registry it reads, instead of a static call - #24

Open
nikolaystrikhar wants to merge 2 commits into
12B-notices-queue-optionfrom
12C-registry-reader
Open

12C: Hand every pass the registry it reads, instead of a static call#24
nikolaystrikhar wants to merge 2 commits into
12B-notices-queue-optionfrom
12C-registry-reader

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: adds Registry_Reader, moves the registration buffer off Absorber, gives Conflict\Detector and Loader one as a constructor argument, and binds it in Provider.

Usage:

$loader = new Loader( new Registry_Reader( $registrar ), $notices );

$loader->load_all();

Why this way:

The facade sat both above its collaborators and below them. It boots them, and they reached Absorber::all() to walk the registry — an edge pointing back up that no double could stand in for and no test could avoid standing up. Absorber::register() now pushes into the reader and Absorber::all() delegates to it; nothing but Absorber names Absorber.

A pass is complete the moment it is built. Holding its registrar means it no longer needs the container to read, so an unbuildable Registrar_Interface fails while the pass is being built — where an unbuildable Queue_Interface has always failed.

The buffer stays static, because register() is a static call a host makes at plugin-file scope, before there is a container to resolve a registrar from. What changed is only which class pays for that.

Over the source-file cap, at five. Registry_Reader is the seam; Absorber, Detector, Loader and Provider are the four callers it cannot land without.

Conflict\Detector and Loader each reached Absorber::all() to walk the registry,
so the facade sat both above its collaborators -- it boots them -- and below
them, which no double could stand in for and no test could avoid standing up.

The registration buffer moves to Registry_Reader, which is what reads it back
out: Absorber::register() pushes into it, Absorber::all() delegates to it, and
every pass takes one as a constructor argument. The buffer stays static because
register() is a static call made before there is a container, but nothing except
Absorber now names Absorber.

A pass that holds its registrar no longer needs the container to read, so an
unbuildable Registrar_Interface now fails while the pass is being built -- where
an unbuildable Queue_Interface or Plugin_Checker_Interface has always failed. A
duplicate slug still surfaces from the read, as Config_Exception, which is what
the guarded read exists to catch.
Every new PHP file declares strict_types, so the rule arrives with the file
rather than as a sweep over it afterwards. PR 21 covers everything that already
existed on main.

@d4mation d4mation left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a bit to understand why Registry_Reader is named the way it is, but once I realized it was to read the Registrar object in the same buffered way as before it made more sense :)

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