Skip to content

Releases: nette/di

Released version 3.2.7

Choose a tag to compare

@dg dg released this 27 Aug 01:17

The container stops being a black box. This release adds a first-class introspection API, a PSR-11 bridge, and – finally – containers that actually reload themselves in long-running processes instead of silently serving a stale build forever. A handful of quiet misconfigurations were also promoted to loud errors.

✨ New Features

  • Containers now reload themselves in long-running processes. Until now, auto-rebuild only ever helped the next request: PHP cannot redeclare a class that is already loaded, so a queue worker, a dev server, a CLI tool or an MCP server kept serving the very first compiled container for the rest of its life, no matter how many times the configs changed and the file on disk was regenerated. With auto-rebuild on, ContainerLoader now gives every build a fresh class name (Container_<key>_<hash>) and, on every load(), checks the compiled file's content rather than merely whether it has just been regenerated, so a rebuild done by another process over the same cache (a web request while your worker runs) is picked up as well. A process simply gets a new container instance whenever its configuration changed, with no restart. Without auto-rebuild nothing changes: production still compiles once and never looks back.
  • New Container::getServiceDescriptors() – a read-only snapshot of every registered service (name, type, autowiring, tags, aliases, and the instance if it exists), in definition order, without instantiating anything. Tools that until now read the container's private properties through Closure::bind() and scanned createService* methods by reflection can drop the tricks; the Tracy panel already has.
  • New Nette\Bridges\DIPsr\PsrContainer – wrap your container and hand it to any library that speaks PSR-11. get() resolves both service names and autowired types, with ambiguity reported rather than guessed.
  • A service produced by a factory can autowire itself in its own setup, so @self and self-typed arguments work there like anywhere else.

🐛 Bug Fixes

  • Windows users: writing the compiled container no longer fails intermittently with "Access is denied" when antivirus or an opcache handle holds the target file for a moment – the rename is briefly retried, and the opcache handle is dropped first. Other platforms behave exactly as before.
  • addService() refuses a name already taken by a factory, matching the existing behavior for instances. The counterpart: removeService() now removes factories too, so a name freed by removeService() is genuinely free.

⚡ Performance

  • Registering a definition no longer scans every existing definition to check for a case-insensitive name clash; an index does it in constant time. Containers with thousands of services notice.

Released version 3.2.6

Choose a tag to compare

@dg dg released this 06 May 01:46

A maintenance release laser-focused on type safety. Static analysis is now mandatory in CI, the codebase ships richer native and PHPDoc types, and the Tracy DI panel got a cleaner Latte rewrite. No behavioral changes – just a sturdier foundation for everything built on top.

  • Native types – tightened parameter and return types across Compiler, ContainerLoader, ServiceDefinition and friends
  • ContainerPanel – Tracy panel template rewritten with n:attributes for noticeably cleaner Latte syntax
  • PHPStan-clean codebase – wide-ranging cleanup across DI internals so the whole tree passes strict analysis
  • Richer PHPDoc – improved @param, @return and class descriptions across Compiler, Container, ContainerBuilder, Resolver, Helpers, definitions and extensions, giving IDEs and static analyzers far more to work with
  • Better generic types – sharpened PHPDoc generics in autowiring, container builder, definitions and resolver

Released version 3.2.5

Choose a tag to compare

@dg dg released this 30 Oct 20:40
  • support for PHP 8.5
  • optimized global function calls
  • used generics for Container::createInstance() (#323)

Released version 3.2.4

Choose a tag to compare

@dg dg released this 10 Jan 05:03
  • implemented support for lazy services in PHP 8.4
  • Resolver: restrictions for named parameters have been removed
  • Resolver: triggers error when reference is called with arguments

Released version 3.2.3

Choose a tag to compare

@dg dg released this 05 Oct 03:06
  • support for PHP 8.4
  • md5 replaced with xxHash
  • fixed ReflectionParameter::getDefaultValue() error #315

Released version 3.2.2

Choose a tag to compare

@dg dg released this 16 May 13:25
  • Container: refactoring
  • NeonAdapter: resolving of constants and enums moved here from filterArguments() (BC break)
  • Container::getServiceType() ignores dynamically added services (BC break)
  • Container::getByType() fixed cooperation with dynamic factory #314
  • Resolver: better exception when normalizeEntity() fails due to service replacement
  • Revert "LocatorDefinition: deprecated support for create($name) method (BC break)"

Released version 3.2.1

Choose a tag to compare

@dg dg released this 04 Mar 13:14
  • PhpGenerator: DTO and DateTime are not suspicious objects #306 #308
  • NeonAdapter: fixed to string conversion #307
  • Compiler::loadDefinitionsFromConfig() expands parameters (after 3399312)

Released version 3.2.0

Choose a tag to compare

@dg dg released this 06 Feb 00:49
  • requires PHP 8.1
  • uses PHP 8.1 features
  • Sensitive parameters are put in markers /sensitive{/ and /}/
  • added support for first-class callable syntax in NEON
  • SearchExtension: added 'exclude -> files'
  • ServicesExtension: locator supports Statement (#294)

changes

  • Resolver: only optional parameters are autowired with default value (BC break)
  • generated accessors/factories must have defined return type (BC break)
  • %parameters% is deprecated (BC break)
  • LocatorDefinition: deprecated support for create($name) method (BC break)
  • PhpGenerator: warns about suspicious dumping of objects

Released version 3.1.10

Choose a tag to compare

@dg dg released this 04 Feb 12:27
  • ParametersExtension: exports both statements and dynamic parameters, preloads only the latter
  • allowed %foo.bar% expansion of Statement
  • SearchExtension: also searches for accessors
  • Resolver::autowireArgument() fixed handling of new-initializer with typehint #302
  • InjectExtension: added type checking
  • NeonAdapter::removeUnderscoreVisitor() checks if key doesn't exist

Released version 3.1.8

Choose a tag to compare

@dg dg released this 15 Oct 12:26
  • ParametersExtension, Container: redesigned way of exporting dynamic parameters via getParameter() #291
  • Helpers::expand() allow concatenation of Statements #288
  • more self explanatory message for factory and service mismatch (closes #199) (#284)
  • Support list<Type> syntax for autowiring a collection of services (#293)
  • Resolver: added support for named variadics #289
  • ParametersExtension: better validation exception for dynamic parameters
  • ContainerPanel: refactoring
  • Container: detects circular reference for parameters
  • ServiceDefinition: prepends @self to setup immediately
  • Option 'class' is allowed again