Skip to content

Releases: thesis-php/dic

0.5.1 Bump minimum PHP version to 8.4.12

Choose a tag to compare

@vudaltsov vudaltsov released this 01 Jul 23:22

Raised the minimum PHP version to 8.4.12, which fixes GH-19044 (protected properties not scoped according to their
prototype). Thanks @roxblnfk for pointing this out!

0.5.0 Autoconfiguration, Module, Dic::closure(), and a lot of other features

Choose a tag to compare

@vudaltsov vudaltsov released this 30 Jun 07:12

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\DICThesis\Dic, class DICDic
  • 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 a Module instance)
  • DIC::function() now returns FunctionConfig; chain ->closure(ClosureT) to get the old typed-closure behaviour
  • DIC::scopedOf()Dic::scoped()
  • DIC::onResolveTags()Dic::onTagResolution(); TagsTaggedRefs
  • Lifetime transientcanBeScoped; Lifetime enum is now internal
  • #[Qualifier]#[Autowire(qualifier: …)]
  • Union types autowired as composite A|B; intersection types A&B now supported
  • Removed: inheritAutowiring(), instance-level bind() / tag(), top-level call(), Thesis\DIC\Mapping namespace

0.4.0 API improvements

Choose a tag to compare

@vudaltsov vudaltsov released this 23 Apr 19:14

Added

  • DIC::function() now supports #[Tag] attributes on the function.
  • DIC::function() now supports #[Singleton] and #[Transient] lifetime attributes on the function (defaults to scoped).

Changed

  • BC break: Move Thesis\DIC\Mapping\doNotAutowire constant to Thesis\DIC\doNotAutowire.
  • BC break: Rename Thesis\DIC\Scope to Scoped.
  • BC break: Rename Thesis\DIC\Configurator\Scope to ScopedOf.
  • BC break: Rename Scope::obtain() to resolve().
  • BC break: Rename DIC::scope() to DIC::scopedOf().
  • BC break: Merge DIC::bind() and bindQualifier() into single DIC::bind(mixed $value, Type $type, string|\Stringable|\UnitEnum $qualifier = '').
  • BC break: Autowiring now matches bindings by exact type only.
  • BC break: DIC::bind() and Scoped::with() now override previous bindings.

Removed

  • BC break: DIC::install() — use DIC::init().
  • BC break: Constants singleton, scoped, transient — use Lifetime::* directly.
  • BC break: Scope::$value property — use Scoped::resolve().

0.3.4 Add Scope::obtain() instead of $value, do not memoize scoped service inside Scope

Choose a tag to compare

@vudaltsov vudaltsov released this 14 Apr 16:38
Add Scope::obtain() instead of $value, do not memoize scoped service …

0.3.3 DIC::init()

Choose a tag to compare

@vudaltsov vudaltsov released this 14 Apr 15:10
Install() deprecated since 0.3.3

0.3.2 Fix thesis/formatter namespaces

Choose a tag to compare

@vudaltsov vudaltsov released this 14 Apr 14:24
Remove @phpstan-ignore generics.variance

0.3.1 Require stable typhoon/formatter and typhoon/type

Choose a tag to compare

@vudaltsov vudaltsov released this 14 Apr 14:20
Require stable typhoon/formatter and typhoon/type

0.3.0 Give it a try!

Choose a tag to compare

@vudaltsov vudaltsov released this 09 Apr 21:32
Add messages to exceptions

0.1.0 Let's go!

Choose a tag to compare

@vudaltsov vudaltsov released this 08 Feb 04:59
Rewrite from scratch