From cef05cd0cca360e233d8158eb83550b06196cca3 Mon Sep 17 00:00:00 2001 From: Nikolay Strikhar Date: Thu, 13 Aug 2026 14:16:01 +0200 Subject: [PATCH] Give the registry a folder of its own The two classes that hold and read the registered sub-plugins sat in the root of src/ beside the facades, and the interface one of them implements sat in src/Contracts/ with everything else that happened not to have a folder. They are now src/Registry/: Registrar, Reader and Contracts/Registrar_Interface, which is the arrangement Conflict/ and Notices/ already have -- the folder carries the subject, the class carries the job. Only Registry_Reader is renamed, to Registry\Reader, because the folder now says the half its old name was spelling out. Registrar keeps its name and so does Registrar_Interface: the alternative that reads better in isolation, Registry\Store, collides with Notices\Store in the two files that name both, and renaming a host seam is free only until 1.0.0 tags. --- CLAUDE.md | 27 +++++++++---------- docs/extending.md | 6 ++--- src/Absorber.php | 9 ++++--- src/Conflict/Detector.php | 8 +++--- src/Conflict/Resolver.php | 10 +++---- src/Conflict/Rewriter.php | 8 +++--- src/Loader.php | 9 ++++--- src/Provider.php | 18 +++++++------ .../Contracts/Registrar_Interface.php | 2 +- .../Reader.php} | 7 ++--- src/{ => Registry}/Registrar.php | 5 ++-- tests/_support/Absorber_State.php | 6 ++--- tests/_support/Spy_Registrar.php | 2 +- tests/_support/Stub_Registry_Reader.php | 4 +-- tests/unit/AbsorberTest.php | 4 +-- tests/unit/Conflict/ResolverTest.php | 8 +++--- tests/unit/LoaderTest.php | 4 +-- tests/unit/ProviderTest.php | 16 +++++------ .../ReaderTest.php} | 14 +++++----- tests/unit/{ => Registry}/RegistrarTest.php | 6 ++--- tests/unit/Scenario/HostTest.php | 2 +- 21 files changed, 90 insertions(+), 85 deletions(-) rename src/{ => Registry}/Contracts/Registrar_Interface.php (93%) rename src/{Registry_Reader.php => Registry/Reader.php} (96%) rename src/{ => Registry}/Registrar.php (92%) rename tests/unit/{Registry_ReaderTest.php => Registry/ReaderTest.php} (94%) rename tests/unit/{ => Registry}/RegistrarTest.php (95%) diff --git a/CLAUDE.md b/CLAUDE.md index f2f44e4..58db67e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -79,14 +79,14 @@ seams a host may rebind: | Interface | Bound to | Responsibility | |---|---|---| -| `Contracts\Registrar_Interface` | `Registrar` | holds registered `Sub_Plugin` objects | +| `Registry\Contracts\Registrar_Interface` | `Registry\Registrar` | holds registered `Sub_Plugin` objects | | `Notices\Contracts\Writer_Interface` | `Notices\Writer` | what each notice says | | `Conflict\Contracts\Resolver_Interface` | `Conflict\Resolver` | one method: which policy branch a conflict takes | | `Contracts\Plugin_Deactivator_Interface` | `Plugin_Deactivator` | deactivates the standalone, network-aware | | `Contracts\Plugin_Checker_Interface` | `Plugin_Checker` | answers whether a plugin is active | | `Contracts\Activator_Interface` | `Activator` | run-once activation-callback tracking | -The rest — `Boot\Scheduler`, `Loader`, `Registry_Reader`, `Conflict\Detector`, `Conflict\Gatekeeper`, +The rest — `Boot\Scheduler`, `Loader`, `Registry\Reader`, `Conflict\Detector`, `Conflict\Gatekeeper`, `Conflict\Redirector`, `Conflict\Rewriter`, `Notices\Store`, `Notices\Renderer`, `Notices\Presenter` — are bound as concrete classes. A host that wants one of them different rebinds the class name; there is no interface because nothing in the library dispatches on one. `Provider` also binds the container @@ -95,8 +95,8 @@ unbound classes reflectively can still satisfy the collaborators that take one. An interface belonging to a folder-scoped concern lives in that folder's `Contracts\`, not beside its implementation and not in the top-level `src/Contracts/`. `src/Contracts/` is for the interfaces whose -implementations sit at the root — `Registrar`, `Plugin_Deactivator`, `Plugin_Checker`, `Activator` — -plus `Provider_Interface`. +implementations sit at the root — `Plugin_Deactivator`, `Plugin_Checker`, `Activator` — plus +`Provider_Interface`. **`Notices\Writer` and `Notices\Presenter` split because they change for different reasons.** One answers "what does this notice say", the other "who may see the pending set, and is it gone once they @@ -145,7 +145,7 @@ Foundation's abstract does not extend. **`Provider` never overwrites a binding.** It binds only what the container does not already have, so a host that bound its own implementation wins, and the order in which the host calls `set_container()` and `boot()` stops deciding which implementation it gets. Everything is a -singleton: each binding is either a registry whose contents are the point — a second `Registrar` +singleton: each binding is either a registry whose contents are the point — a second `Registry\Registrar` would hold a second, emptier list — or a stateless worker with nothing to gain from a second copy. The container is **never** used to wire hooks, and the reason is no longer that it is optional. @@ -161,7 +161,7 @@ collaborator to be built at boot. delegations to `$container->get()`, so what a host calls is unchanged; what changed is that a *collaborator* now depends on the peer it was handed rather than on the facade. -**Nothing but `Absorber` names `Absorber`.** The registration buffer belongs to `Registry_Reader`, +**Nothing but `Absorber` names `Absorber`.** The registration buffer belongs to `Registry\Reader`, which is also what reads it back out: `Absorber::register()` pushes a `Sub_Plugin` into it and `Absorber::all()` delegates to it, while `Conflict\Detector`, `Conflict\Resolver` and `Loader` are each handed one. The buffer is static because it must be — `register()` is a static call a host makes @@ -195,13 +195,12 @@ that drives the whole of it against a real WordPress is `tests/unit/Scenario/`. | `src/Sub_Plugin.php` | Value object; validates config and answers what it can without a container-bound collaborator. | | `src/Conflict_Policy.php` | The three policy constants, `default()`, `is_valid()`. | | `src/Plugin_Deactivator.php`, `src/Plugin_Checker.php` | The only files that touch WordPress plugin functions, through `Traits\Loads_Plugin_Functions`. | -| `src/Registrar.php` | Holds registered `Sub_Plugin` objects. | -| `src/Registry_Reader.php` | The registration buffer, drained into the registrar on the way past; the object every pass reads the registry through. | +| `src/Registry/` | `Registrar` (holds registered `Sub_Plugin` objects), `Reader` (the registration buffer, drained into the registrar on the way past; the object every pass reads the registry through), `Contracts\Registrar_Interface`. | | `src/Activator.php` | Runs a sub-plugin's activation callback once ever, recorded in one option. | | `src/Conflict/` | `Detector` (whether a standalone is in the way), `Resolver` (which policy branch to take), `Gatekeeper` (which requests, and which users, may have one resolved), `Redirector` (where the user lands afterwards), `Rewriter` (rewrites the activation-error screen for a registered standalone), `Contracts\Resolver_Interface`. | | `src/Traits/` | `Loads_Plugin_Functions` (pulls in `wp-admin/includes/plugin.php`), `Guards_Hook_Prefix` (a missing prefix warns and stands down rather than throwing). | | `src/Notices/` | `Writer` (what a notice says, stored under `slug:type`), `Presenter` (who may consume it, render-then-clear), `Store` (keeps it), `Renderer` (draws it), `Contracts\Writer_Interface`. | -| `src/Contracts/`, `src/Exceptions/` | `Provider_Interface`, `Registrar_Interface`, `Plugin_Deactivator_Interface`, `Plugin_Checker_Interface`, `Activator_Interface`, `Config_Exception`. | +| `src/Contracts/`, `src/Exceptions/` | `Provider_Interface`, `Plugin_Deactivator_Interface`, `Plugin_Checker_Interface`, `Activator_Interface`, `Config_Exception`. | ### Boot lifecycle @@ -229,7 +228,7 @@ whenever the host's bootstrap happens to run it. This is also why `Absorber::reg resolves nothing — registration at plugin-file scope is a shape a host is entitled to use, and it would otherwise register into the throwaway. -**A duplicate slug is `Registrar::register()`'s exception, not `Absorber::register()`'s.** What +**A duplicate slug is `Registry\Registrar::register()`'s exception, not `Absorber::register()`'s.** What `Absorber::register()` throws is config validation, from the `Sub_Plugin` constructor, in the call the host can see in its own stack trace. The buffer reaches the registrar at the first read — `plugins_loaded` priority 5 on a request that passes the gatekeeper, priority 6 otherwise — so the @@ -275,7 +274,7 @@ carries the whole re-declaration guarantee, and it is the only gate meaning "thi running" — warning that requirements are unmet for a plugin the admin can watch working would send them after the wrong problem. `docs/filters.md` says the same. -`Registry_Reader::all()` narrows to `Sub_Plugin` instances itself, so no caller repeats that guard. A +`Registry\Reader::all()` narrows to `Sub_Plugin` instances itself, so no caller repeats that guard. A host may bind a registrar returning anything, and PHP 7.4 cannot express `array` in the interface signature — so it is filtered once where the untrusted value enters. All three readers — the load pass, the conflict pass and `Conflict\Rewriter` — read through the reader they were @@ -365,7 +364,7 @@ all this library gets to do about it is reword the sentence core's sandbox print `conflict_notice_message`, the same message the merge notice carries, but wording it is as far as the two share: nothing in `Rewriter` is stored, drawn or authored through the notice machinery — it reads the request, checks the screen, verifies a nonce and edits markup core already wrote. Putting it on -`Writer` anyway would have needed a `Registry_Reader` argument for the one method that used it — a +`Writer` anyway would have needed a `Registry\Reader` argument for the one method that used it — a collaborator only that method needs — and would have forced every host binding its own `Notices\Contracts\Writer_Interface` to implement an error screen just to get its notices worded. It sits in `Conflict\` rather than `Notices\` because what it is about is the standalone conflict — the @@ -452,9 +451,9 @@ Tabs for PHP, 4 spaces for yml/yaml/json/md (see `.editorconfig`). Production classes do not get a `reset()` for the suite's benefit — that becomes API the library supports forever. Tests clear static state by reflection through a helper under `tests/_support/`: `Tests\Support\Config_State::reset()` for `Config`, and `Tests\Support\Absorber_State::reset()` for -`Absorber` plus the registration buffer on `Registry_Reader`, which also unwires the hooks `boot()` +`Absorber` plus the registration buffer on `Registry\Reader`, which also unwires the hooks `boot()` added. Any older sketch showing `Config::reset()` or `Absorber::reset()` means the support helper. -`Registrar` needs no such helper — its state is instance state behind a container binding, so a +`Registry\Registrar` needs no such helper — its state is instance state behind a container binding, so a fresh container *is* the reset. ### Testing rules diff --git a/docs/extending.md b/docs/extending.md index ba8c382..c1a35e4 100644 --- a/docs/extending.md +++ b/docs/extending.md @@ -10,14 +10,14 @@ Bind any of these ids before or after `Absorber::boot()` — boot binds the defa *interface* your container already answers for, so your binding wins either way: ```php -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; $container->singleton( Registrar_Interface::class, My_Registrar::class ); ``` | Interface | Default | Responsibility | |---|---|---| -| `Contracts\Registrar_Interface` | `Registrar` | Holds the registered sub-plugins. | +| `Registry\Contracts\Registrar_Interface` | `Registry\Registrar` | Holds the registered sub-plugins. | | `Notices\Contracts\Writer_Interface` | `Notices\Writer` | Words the admin notices. | | `Contracts\Plugin_Deactivator_Interface` | `Plugin_Deactivator` | Deactivates the standalone. | | `Contracts\Plugin_Checker_Interface` | `Plugin_Checker` | Answers whether a plugin is active. | @@ -36,7 +36,7 @@ want. See [the recipe](recipes.md#do-per-site-work-on-multisite). Everything without an interface is bound by class name — `Notices\Store`, `Notices\Renderer`, `Notices\Presenter`, `Conflict\Detector`, `Conflict\Gatekeeper`, `Conflict\Redirector`, -`Conflict\Rewriter`, `Loader`, `Registry_Reader`, `Boot\Scheduler`. Bind one of those **after** +`Conflict\Rewriter`, `Loader`, `Registry\Reader`, `Boot\Scheduler`. Bind one of those **after** `Absorber::boot()`: di52 reports `has()` true for any class that exists, bound or not, so boot cannot tell your binding from the container's own willingness to build the class, and replaces it. diff --git a/src/Absorber.php b/src/Absorber.php index e5e6550..6df1dd6 100644 --- a/src/Absorber.php +++ b/src/Absorber.php @@ -9,10 +9,11 @@ use Nexcess\PluginAbsorber\Conflict\Contracts\Resolver_Interface; use Nexcess\PluginAbsorber\Conflict\Rewriter; use Nexcess\PluginAbsorber\Contracts\Provider_Interface; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; use Nexcess\PluginAbsorber\Notices\Presenter; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Traits\Guards_Hook_Prefix; use Throwable; @@ -78,7 +79,7 @@ public static function resolver(): Resolver_Interface { * The sub-plugin is buffered rather than handed straight to the registrar, so that registering * resolves nothing — not even the container. A host that registers before it calls * Config::set_container() would otherwise fail on a call that has nothing to do with the - * container. The buffer belongs to `Registry_Reader`, which is where it is read back out: this + * container. The buffer belongs to `Registry\Reader`, which is where it is read back out: this * class hands its collaborators no work and holds none of their state. * * The configuration is still validated here: building the Sub_Plugin is what rejects it, and @@ -95,7 +96,7 @@ public static function resolver(): Resolver_Interface { * @return void */ public static function register( array $config ): void { - Registry_Reader::buffer( new Sub_Plugin( $config ) ); + Reader::buffer( new Sub_Plugin( $config ) ); } /** @@ -114,7 +115,7 @@ public static function register( array $config ): void { * @return array */ public static function all(): array { - return self::collaborator( Registry_Reader::class )->all(); + return self::collaborator( Reader::class )->all(); } /** diff --git a/src/Conflict/Detector.php b/src/Conflict/Detector.php index 775a285..c2ac81e 100644 --- a/src/Conflict/Detector.php +++ b/src/Conflict/Detector.php @@ -9,7 +9,7 @@ use Nexcess\PluginAbsorber\Contracts\Plugin_Checker_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; /** @@ -34,7 +34,7 @@ class Detector { /** * @since 1.0.0 * - * @var Registry_Reader + * @var Reader */ private $registry; @@ -48,10 +48,10 @@ class Detector { /** * @since 1.0.0 * - * @param Registry_Reader $registry Which sub-plugins are registered. + * @param Reader $registry Which sub-plugins are registered. * @param Plugin_Checker_Interface $plugin_checker Whether the standalone is active. */ - public function __construct( Registry_Reader $registry, Plugin_Checker_Interface $plugin_checker ) { + public function __construct( Reader $registry, Plugin_Checker_Interface $plugin_checker ) { $this->registry = $registry; $this->plugin_checker = $plugin_checker; } diff --git a/src/Conflict/Resolver.php b/src/Conflict/Resolver.php index 54f0c85..c8d1e88 100644 --- a/src/Conflict/Resolver.php +++ b/src/Conflict/Resolver.php @@ -12,7 +12,7 @@ use Nexcess\PluginAbsorber\Contracts\Plugin_Deactivator_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; use Nexcess\PluginAbsorber\Traits\Guards_Hook_Prefix; use Throwable; @@ -41,7 +41,7 @@ class Resolver implements Resolver_Interface { /** * @since 1.0.0 * - * @var Registry_Reader + * @var Reader */ private $registry; @@ -76,14 +76,14 @@ class Resolver implements Resolver_Interface { /** * @since 1.0.0 * - * @param Registry_Reader $registry Which sub-plugins are registered. + * @param Reader $registry Which sub-plugins are registered. * @param Detector $detector Whether a sub-plugin is in conflict. * @param Plugin_Deactivator_Interface $plugin_deactivator Turns the standalone off. - * @param Writer_Interface $notices Where the user is told what happened. + * @param Writer_Interface $notices Where the user is told what happened. * @param Redirector $redirector Where the user lands afterwards. */ public function __construct( - Registry_Reader $registry, + Reader $registry, Detector $detector, Plugin_Deactivator_Interface $plugin_deactivator, Writer_Interface $notices, diff --git a/src/Conflict/Rewriter.php b/src/Conflict/Rewriter.php index 45c0cfc..5953826 100644 --- a/src/Conflict/Rewriter.php +++ b/src/Conflict/Rewriter.php @@ -8,7 +8,7 @@ namespace Nexcess\PluginAbsorber\Conflict; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; /** @@ -38,16 +38,16 @@ class Rewriter { /** * @since 1.0.0 * - * @var Registry_Reader + * @var Reader */ private $registry; /** * @since 1.0.0 * - * @param Registry_Reader $registry Which sub-plugins are registered. + * @param Reader $registry Which sub-plugins are registered. */ - public function __construct( Registry_Reader $registry ) { + public function __construct( Reader $registry ) { $this->registry = $registry; } diff --git a/src/Loader.php b/src/Loader.php index 25c11d3..960b544 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -8,6 +8,7 @@ use Nexcess\PluginAbsorber\Contracts\Activator_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Traits\Guards_Hook_Prefix; use Throwable; @@ -26,7 +27,7 @@ class Loader { /** * @since 1.0.0 * - * @var Registry_Reader + * @var Reader */ private $registry; @@ -47,12 +48,12 @@ class Loader { /** * @since 1.0.0 * - * @param Registry_Reader $registry Which sub-plugins are registered. - * @param Writer_Interface $notices Where a sub-plugin that could not load says so. + * @param Reader $registry Which sub-plugins are registered. + * @param Writer_Interface $notices Where a sub-plugin that could not load says so. * @param Activator_Interface $activator Runs the activation callback of one that did. */ public function __construct( - Registry_Reader $registry, + Reader $registry, Writer_Interface $notices, Activator_Interface $activator ) { diff --git a/src/Provider.php b/src/Provider.php index d1bf840..22d3448 100644 --- a/src/Provider.php +++ b/src/Provider.php @@ -16,13 +16,15 @@ use Nexcess\PluginAbsorber\Contracts\Plugin_Checker_Interface; use Nexcess\PluginAbsorber\Contracts\Plugin_Deactivator_Interface; use Nexcess\PluginAbsorber\Contracts\Provider_Interface; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Loader; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; use Nexcess\PluginAbsorber\Notices\Presenter; use Nexcess\PluginAbsorber\Notices\Renderer; use Nexcess\PluginAbsorber\Notices\Store; use Nexcess\PluginAbsorber\Notices\Writer; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Reader; +use Nexcess\PluginAbsorber\Registry\Registrar; use StellarWP\ContainerContract\ContainerInterface; /** @@ -94,16 +96,16 @@ static function () use ( $container ): Presenter { ); $this->bind_once( - Registry_Reader::class, - static function () use ( $container ): Registry_Reader { - return new Registry_Reader( $container->get( Registrar_Interface::class ) ); + Reader::class, + static function () use ( $container ): Reader { + return new Reader( $container->get( Registrar_Interface::class ) ); } ); $this->bind_once( Rewriter::class, static function () use ( $container ): Rewriter { - return new Rewriter( $container->get( Registry_Reader::class ) ); + return new Rewriter( $container->get( Reader::class ) ); } ); @@ -111,7 +113,7 @@ static function () use ( $container ): Rewriter { Detector::class, static function () use ( $container ): Detector { return new Detector( - $container->get( Registry_Reader::class ), + $container->get( Reader::class ), $container->get( Plugin_Checker_Interface::class ) ); } @@ -121,7 +123,7 @@ static function () use ( $container ): Detector { Resolver_Interface::class, static function () use ( $container ): Resolver { return new Resolver( - $container->get( Registry_Reader::class ), + $container->get( Reader::class ), $container->get( Detector::class ), $container->get( Plugin_Deactivator_Interface::class ), $container->get( Writer_Interface::class ), @@ -134,7 +136,7 @@ static function () use ( $container ): Resolver { Loader::class, static function () use ( $container ): Loader { return new Loader( - $container->get( Registry_Reader::class ), + $container->get( Reader::class ), $container->get( Writer_Interface::class ), $container->get( Activator_Interface::class ) ); diff --git a/src/Contracts/Registrar_Interface.php b/src/Registry/Contracts/Registrar_Interface.php similarity index 93% rename from src/Contracts/Registrar_Interface.php rename to src/Registry/Contracts/Registrar_Interface.php index 27f54c1..91c7689 100644 --- a/src/Contracts/Registrar_Interface.php +++ b/src/Registry/Contracts/Registrar_Interface.php @@ -3,7 +3,7 @@ * @package Nexcess\PluginAbsorber */ -namespace Nexcess\PluginAbsorber\Contracts; +namespace Nexcess\PluginAbsorber\Registry\Contracts; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Sub_Plugin; diff --git a/src/Registry_Reader.php b/src/Registry/Reader.php similarity index 96% rename from src/Registry_Reader.php rename to src/Registry/Reader.php index d53b7d4..0725944 100644 --- a/src/Registry_Reader.php +++ b/src/Registry/Reader.php @@ -5,10 +5,11 @@ declare( strict_types=1 ); -namespace Nexcess\PluginAbsorber; +namespace Nexcess\PluginAbsorber\Registry; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Sub_Plugin; /** * Every registered sub-plugin, as something a pass can be handed rather than reach for. @@ -29,7 +30,7 @@ * * @since 1.0.0 */ -class Registry_Reader { +class Reader { /** * Sub-plugins registered but not yet handed to the registrar. * diff --git a/src/Registrar.php b/src/Registry/Registrar.php similarity index 92% rename from src/Registrar.php rename to src/Registry/Registrar.php index 3c0ca7d..353a4d8 100644 --- a/src/Registrar.php +++ b/src/Registry/Registrar.php @@ -3,10 +3,11 @@ * @package Nexcess\PluginAbsorber */ -namespace Nexcess\PluginAbsorber; +namespace Nexcess\PluginAbsorber\Registry; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Sub_Plugin; /** * Default registry: a plain slug => Sub_Plugin map. diff --git a/tests/_support/Absorber_State.php b/tests/_support/Absorber_State.php index e0596ad..38c4b75 100644 --- a/tests/_support/Absorber_State.php +++ b/tests/_support/Absorber_State.php @@ -8,7 +8,7 @@ use Closure; use LogicException; use Nexcess\PluginAbsorber\Absorber; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use ReflectionClass; use ReflectionFunction; use ReflectionProperty; @@ -29,7 +29,7 @@ class Absorber_State { /** * The value each static property of the boot path starts life with, by the class holding it. * - * Two classes, because the registration buffer belongs to `Registry_Reader` — a host registers + * Two classes, because the registration buffer belongs to `Registry\Reader` — a host registers * before there is a container to reach a registrar through, so the pre-store is static, and it * sits with the object that reads it rather than with the facade that writes to it. A test that * cleared only the facade would leave one test's registrations to drain into the next test's @@ -43,7 +43,7 @@ class Absorber_State { */ protected const DEFAULTS = [ Absorber::class => [ 'booted' => false ], - Registry_Reader::class => [ 'pending' => [] ], + Reader::class => [ 'pending' => [] ], ]; /** diff --git a/tests/_support/Spy_Registrar.php b/tests/_support/Spy_Registrar.php index b87d180..40402ad 100644 --- a/tests/_support/Spy_Registrar.php +++ b/tests/_support/Spy_Registrar.php @@ -5,7 +5,7 @@ namespace Nexcess\PluginAbsorber\Tests\Support; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Sub_Plugin; /** diff --git a/tests/_support/Stub_Registry_Reader.php b/tests/_support/Stub_Registry_Reader.php index 9cc56ae..cf16528 100644 --- a/tests/_support/Stub_Registry_Reader.php +++ b/tests/_support/Stub_Registry_Reader.php @@ -7,7 +7,7 @@ namespace Nexcess\PluginAbsorber\Tests\Support; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; /** @@ -24,7 +24,7 @@ * * @since 1.0.0 */ -class Stub_Registry_Reader extends Registry_Reader { +class Stub_Registry_Reader extends Reader { /** * What every read hands back, keyed by slug. * diff --git a/tests/unit/AbsorberTest.php b/tests/unit/AbsorberTest.php index f49c06c..db179bc 100644 --- a/tests/unit/AbsorberTest.php +++ b/tests/unit/AbsorberTest.php @@ -11,11 +11,11 @@ use Nexcess\PluginAbsorber\Config; use Nexcess\PluginAbsorber\Conflict\Resolver; use Nexcess\PluginAbsorber\Conflict\Rewriter; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Notices\Presenter; use Nexcess\PluginAbsorber\Notices\Writer; -use Nexcess\PluginAbsorber\Registrar; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Registrar; use Nexcess\PluginAbsorber\Sub_Plugin; use Nexcess\PluginAbsorber\Tests\Support\Absorber_State; use Nexcess\PluginAbsorber\Tests\Support\Config_State; diff --git a/tests/unit/Conflict/ResolverTest.php b/tests/unit/Conflict/ResolverTest.php index 51ebc34..44a5f9b 100644 --- a/tests/unit/Conflict/ResolverTest.php +++ b/tests/unit/Conflict/ResolverTest.php @@ -20,7 +20,7 @@ use Nexcess\PluginAbsorber\Contracts\Plugin_Deactivator_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; use Nexcess\PluginAbsorber\Tests\Support\Absorber_State; use Nexcess\PluginAbsorber\Tests\Support\Config_State; @@ -30,9 +30,9 @@ use Nexcess\PluginAbsorber\Tests\Support\TestException; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithContainer; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithHaltedRedirects; +use Nexcess\PluginAbsorber\Tests\Support\Traits\WithIncorrectUsage; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithNoticeQueue; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithRequestMethod; -use Nexcess\PluginAbsorber\Tests\Support\Traits\WithIncorrectUsage; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithSubPlugins; use RuntimeException; @@ -176,8 +176,8 @@ public function test_it_resolves_the_registry_it_was_handed(): void { // not anybody bound it -- so the provider binds its own regardless, and a double put in first // would be silently replaced. $this->container()->singleton( - Registry_Reader::class, - static function () use ( $reader ): Registry_Reader { + Reader::class, + static function () use ( $reader ): Reader { return $reader; } ); diff --git a/tests/unit/LoaderTest.php b/tests/unit/LoaderTest.php index c9b966b..4b658a2 100644 --- a/tests/unit/LoaderTest.php +++ b/tests/unit/LoaderTest.php @@ -10,9 +10,9 @@ use Nexcess\PluginAbsorber\Absorber; use Nexcess\PluginAbsorber\Config; use Nexcess\PluginAbsorber\Contracts\Activator_Interface; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Loader; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Sub_Plugin; use Nexcess\PluginAbsorber\Tests\Support\Absorber_State; use Nexcess\PluginAbsorber\Tests\Support\Config_State; @@ -558,7 +558,7 @@ public function test_a_skipped_sub_plugin_does_not_stop_the_others(): void { /** * Registrar_Interface::all() can only declare `array`, so a host implementation is free to return - * anything. The default Registrar cannot produce this state — only a bound one can. + * anything. The default `Registry\Registrar` cannot produce this state — only a bound one can. */ public function test_it_ignores_entries_that_are_not_sub_plugins(): void { $constant = $this->make_guard_constant(); diff --git a/tests/unit/ProviderTest.php b/tests/unit/ProviderTest.php index 0d8e0c3..bcea06a 100644 --- a/tests/unit/ProviderTest.php +++ b/tests/unit/ProviderTest.php @@ -7,18 +7,17 @@ use Codeception\TestCase\WPTestCase; use Generator; +use Nexcess\PluginAbsorber\Activator; use Nexcess\PluginAbsorber\Boot\Scheduler; use Nexcess\PluginAbsorber\Conflict\Contracts\Resolver_Interface; use Nexcess\PluginAbsorber\Conflict\Detector; use Nexcess\PluginAbsorber\Conflict\Gatekeeper; use Nexcess\PluginAbsorber\Conflict\Redirector; use Nexcess\PluginAbsorber\Conflict\Resolver; -use Nexcess\PluginAbsorber\Activator; use Nexcess\PluginAbsorber\Contracts\Activator_Interface; use Nexcess\PluginAbsorber\Contracts\Plugin_Checker_Interface; use Nexcess\PluginAbsorber\Contracts\Plugin_Deactivator_Interface; use Nexcess\PluginAbsorber\Contracts\Provider_Interface; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Loader; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; use Nexcess\PluginAbsorber\Notices\Presenter; @@ -28,13 +27,14 @@ use Nexcess\PluginAbsorber\Plugin_Checker; use Nexcess\PluginAbsorber\Plugin_Deactivator; use Nexcess\PluginAbsorber\Provider; -use Nexcess\PluginAbsorber\Registrar; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Reader; +use Nexcess\PluginAbsorber\Registry\Registrar; use Nexcess\PluginAbsorber\Tests\Support\Config_State; use Nexcess\PluginAbsorber\Tests\Support\Spy_Activator; use Nexcess\PluginAbsorber\Tests\Support\Spy_Registrar; -use Nexcess\PluginAbsorber\Tests\Support\Spy_Writer; use Nexcess\PluginAbsorber\Tests\Support\Spy_Resolver; +use Nexcess\PluginAbsorber\Tests\Support\Spy_Writer; use Nexcess\PluginAbsorber\Tests\Support\Test_Container; use StellarWP\ContainerContract\ContainerInterface; @@ -83,7 +83,7 @@ public function test_it_binds_every_default( string $id, string $expected ): voi */ public static function default_bindings(): Generator { yield 'the registrar' => [ Registrar_Interface::class, Registrar::class ]; - yield 'the registry reader' => [ Registry_Reader::class, Registry_Reader::class ]; + yield 'the registry reader' => [ Reader::class, Reader::class ]; yield 'the notice writer' => [ Writer_Interface::class, Writer::class ]; yield 'the notice store' => [ Store::class, Store::class ]; yield 'the notice renderer' => [ Renderer::class, Renderer::class ]; @@ -120,7 +120,7 @@ public function test_a_binding_resolves_to_one_instance( string $id ): void { */ public static function single_instance_bindings(): Generator { yield 'the registrar' => [ Registrar_Interface::class ]; - yield 'the registry reader' => [ Registry_Reader::class ]; + yield 'the registry reader' => [ Reader::class ]; yield 'the notice writer' => [ Writer_Interface::class ]; yield 'the notice store' => [ Store::class ]; yield 'the notice renderer' => [ Renderer::class ]; @@ -159,7 +159,7 @@ public function test_it_binds_a_class_id_the_container_reports_it_already_has( s * @return Generator */ public static function class_id_bindings(): Generator { - yield 'the registry reader' => [ Registry_Reader::class ]; + yield 'the registry reader' => [ Reader::class ]; yield 'the notice store' => [ Store::class ]; yield 'the notice renderer' => [ Renderer::class ]; yield 'the notice presenter' => [ Presenter::class ]; diff --git a/tests/unit/Registry_ReaderTest.php b/tests/unit/Registry/ReaderTest.php similarity index 94% rename from tests/unit/Registry_ReaderTest.php rename to tests/unit/Registry/ReaderTest.php index 60bf962..bc5ef07 100644 --- a/tests/unit/Registry_ReaderTest.php +++ b/tests/unit/Registry/ReaderTest.php @@ -5,14 +5,14 @@ declare( strict_types=1 ); -namespace Nexcess\PluginAbsorber\Tests\Unit; +namespace Nexcess\PluginAbsorber\Tests\Unit\Registry; use Codeception\TestCase\WPTestCase; use Nexcess\PluginAbsorber\Absorber; use Nexcess\PluginAbsorber\Config; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; -use Nexcess\PluginAbsorber\Registry_Reader; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Reader; use Nexcess\PluginAbsorber\Sub_Plugin; use Nexcess\PluginAbsorber\Tests\Support\Absorber_State; use Nexcess\PluginAbsorber\Tests\Support\Config_State; @@ -33,7 +33,7 @@ * * @since 1.0.0 */ -class Registry_ReaderTest extends WPTestCase { +class ReaderTest extends WPTestCase { use WithContainer; public function setUp(): void { @@ -171,10 +171,10 @@ static function (): Registrar_Interface { /** * The reader the container builds, which is the one every pass is handed. * - * @return Registry_Reader + * @return Reader */ - private function reader(): Registry_Reader { - return $this->resolve( Registry_Reader::class ); + private function reader(): Reader { + return $this->resolve( Reader::class ); } /** diff --git a/tests/unit/RegistrarTest.php b/tests/unit/Registry/RegistrarTest.php similarity index 95% rename from tests/unit/RegistrarTest.php rename to tests/unit/Registry/RegistrarTest.php index cf4ffae..ecb3f24 100644 --- a/tests/unit/RegistrarTest.php +++ b/tests/unit/Registry/RegistrarTest.php @@ -3,12 +3,12 @@ * @package Nexcess\PluginAbsorber */ -namespace Nexcess\PluginAbsorber\Tests\Unit; +namespace Nexcess\PluginAbsorber\Tests\Unit\Registry; use Codeception\TestCase\WPTestCase; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Exceptions\Config_Exception; -use Nexcess\PluginAbsorber\Registrar; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; +use Nexcess\PluginAbsorber\Registry\Registrar; use Nexcess\PluginAbsorber\Tests\Support\Traits\WithSubPlugins; /** diff --git a/tests/unit/Scenario/HostTest.php b/tests/unit/Scenario/HostTest.php index 3cdd2c6..ea3b348 100644 --- a/tests/unit/Scenario/HostTest.php +++ b/tests/unit/Scenario/HostTest.php @@ -15,8 +15,8 @@ use Nexcess\PluginAbsorber\Contracts\Activator_Interface; use Nexcess\PluginAbsorber\Contracts\Plugin_Checker_Interface; use Nexcess\PluginAbsorber\Contracts\Plugin_Deactivator_Interface; -use Nexcess\PluginAbsorber\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Notices\Contracts\Writer_Interface; +use Nexcess\PluginAbsorber\Registry\Contracts\Registrar_Interface; use Nexcess\PluginAbsorber\Tests\Support\Spy_Activator; use Nexcess\PluginAbsorber\Tests\Support\Spy_Gatekeeper; use Nexcess\PluginAbsorber\Tests\Support\Spy_Registrar;