Resolver-Interop Now Open For Public Review
I am pleased to announce that the Resolver-Interop standard interface package is now open for public review.
Resolver-Interop provides an interoperable package of standard interfaces for autowiring resolver functionality in PHP 8.4 or later. It reflects, refines, and reconciles the common practices identified within several pre-existing projects to define these interfaces:
-
ClassResolver to afford resolving a class to a new instance with autowired arguments;
-
Parameter-, setter-, and property-injection attributes and their related orchestrations;
-
CallResolver to afford invoking a callable with autowired arguments;
-
Resolvable, which lets callers pass deferred container lookups in argument arrays without forcing the lookup at construction time; and,
-
ResolverThrowable to mark exceptions as resolver-related.
Where the researched projects typically expose autowiring through a single
container class with several methods (get(), make(), call(), and so on),
Resolver-Interop splits those operations into separate single-method
interfaces, so consumers can depend on exactly the surface they need and
implementors can combine them as they see fit.
Constructor injection is the documented default across the researched projects, and Resolver-Interop summarises that guidance: constructor injection is preferred above all; setter-injection is supported for cases where it is unavoidable; and property-injection is available as an absolute last resort. The package does not forbid post-construction injection, but it makes the appropriate scope explicit.
Resolver-Interop can be combined with Ioc-Interop to build an autowiring IOC container system.
The reference implementations demonstrate how the interfaces can be used.
Please offer your comments and criticism as issues or PRs out at Github.