Releases: thesis-php/dic
Release list
0.5.1 Bump minimum PHP version to 8.4.12
0.5.0 Autoconfiguration, Module, Dic::closure(), and a lot of other features
What's new in 0.5.0
This release is a significant overhaul — new entry points, autoconfiguration hooks, smarter lifetimes, typed closure services, and a cleaned-up namespace.
There are many BC breaks; see the migration notes below.
Highlights
New entry points
Dic::run(Module $module, callable $main) is now the recommended way to boot an application — it resolves the root service, runs your main callable, and disposes everything (even on throw).
Dic::build(Module $module) is the test-friendly variant that skips disposal.
Modules are typed classes
Module is now an interface (configure(Dic): mixed) instead of a plain callable.
This makes modules discoverable, composable, and IDE-friendly.
Autoconfiguration hooks
onObject() and onFunction() let you apply cross-cutting conventions (tagging, lifetimes, disposers) from one place instead of repeating them per service.
Each listener is scoped to the Dic it was registered on — submodules brought in via import() run in isolation.
Typed closure services
FunctionConfig::closure(ClosureT $type) turns any callable service into a typed \Closure whose dependencies are autowired by the container; parameters declared in the type are left for the caller.
Adaptive lifetime
ObjectConfig::canBeScoped() — scoped when any transitive dependency is scoped, singleton otherwise.
No more guessing the right lifetime for shared-but-sometimes-scoped services.
Post-construction calls
ObjectConfig::call() and ObjectConfig::chain() invoke methods after construction — setters and wither-style builders respectively.
#[Autowire] attribute
Replaces the old #[Qualifier] — overrides the binding qualifier (or disables autowiring) for a single parameter.
Structured disposal errors
DisposalFailed collects all disposer failures instead of stopping at the first one.
The triggering throwable is preserved as getPrevious().
Documentation
All public behaviour is now documented in docs/ — objects, values, functions, arguments, autowiring, tags, modularity, lifetimes, and disposal.
First official module
thesis/symfony-console-module — auto-registers Symfony Console commands from classes and invokable functions annotated with #[AsCommand].
BC breaks
- Namespace:
Thesis\DIC→Thesis\Dic, classDIC→Dic - Configurators:
Thesis\DIC\Configurator\*→Thesis\Dic\Configuration\*Config(see CHANGELOG for full mapping) DIC::init()→Dic::run()/Dic::build()DIC::require(callable)→Dic::import(Module)(now takes aModuleinstance)DIC::function()now returnsFunctionConfig; chain->closure(ClosureT)to get the old typed-closure behaviourDIC::scopedOf()→Dic::scoped()DIC::onResolveTags()→Dic::onTagResolution();Tags→TaggedRefs- Lifetime
transient→canBeScoped;Lifetimeenum is now internal #[Qualifier]→#[Autowire(qualifier: …)]- Union types autowired as composite
A|B; intersection typesA&Bnow supported - Removed:
inheritAutowiring(), instance-levelbind()/tag(), top-levelcall(),Thesis\DIC\Mappingnamespace
0.4.0 API improvements
Added
DIC::function()now supports#[Tag]attributes on the function.DIC::function()now supports#[Singleton]and#[Transient]lifetime attributes on the function (defaults toscoped).
Changed
- BC break: Move
Thesis\DIC\Mapping\doNotAutowireconstant toThesis\DIC\doNotAutowire. - BC break: Rename
Thesis\DIC\ScopetoScoped. - BC break: Rename
Thesis\DIC\Configurator\ScopetoScopedOf. - BC break: Rename
Scope::obtain()toresolve(). - BC break: Rename
DIC::scope()toDIC::scopedOf(). - BC break: Merge
DIC::bind()andbindQualifier()into singleDIC::bind(mixed $value, Type $type, string|\Stringable|\UnitEnum $qualifier = ''). - BC break: Autowiring now matches bindings by exact type only.
- BC break:
DIC::bind()andScoped::with()now override previous bindings.
Removed
- BC break:
DIC::install()— useDIC::init(). - BC break: Constants
singleton,scoped,transient— useLifetime::*directly. - BC break:
Scope::$valueproperty — useScoped::resolve().
0.3.4 Add Scope::obtain() instead of $value, do not memoize scoped service inside Scope
Add Scope::obtain() instead of $value, do not memoize scoped service …
0.3.3 DIC::init()
Install() deprecated since 0.3.3
0.3.2 Fix thesis/formatter namespaces
Remove @phpstan-ignore generics.variance
0.3.1 Require stable typhoon/formatter and typhoon/type
Require stable typhoon/formatter and typhoon/type