Released nette/component-model version 4.0.0 RC

David Grudl
founder | 8315
+
+1
-

A focused, modern major release. The component model drops legacy baggage, demands PHP 8.3+, and ships a smarter monitoring system that finally behaves predictably when listeners reshape the tree. If you've been carrying around deprecated attached()/detached() hooks or the magic getComponents() parameters, this is your cue to clean up – the payoff is a leaner, stricter, more reliable foundation.

  • Monitoring handlers now fire top-down (ancestor → descendant). When a subtree is attached, monitor() listeners are invoked from the outermost ancestor inward, matching the natural order of tree construction. The new implementation is robust against listeners that mutate the tree mid-flight: it re-checks validity before descending into children, deduplicates so the same listener never runs twice, and guards against reentry to prevent infinite loops. If your code relied on the old ordering, review listeners that depend on sibling or parent state.
  • attached() / detached() methods removed. These long-deprecated lifecycle hooks are gone. Migrate to explicit callbacks: replace overridden attached($obj) / detached($obj) with monitor($type, attached: ..., detached: ...). Calling monitor() with no handler at all now throws an InvalidStateException – at least one of attached or detached is required.
  • Container::getComponents() parameters removed. The method now takes no arguments and returns a plain array of immediate children (previously iterable). The old recursive flag and filter-type argument are gone – passing them throws a DeprecatedException. For recursive traversal use getComponentTree() instead. The internal RecursiveComponentIterator has been removed.
  • IContainer::addComponent() signature tightened. Now declared as addComponent(IComponent $component, ?string $name): static. Implementations and callers must match the new return type hint.
  • Nette\SmartObject dropped from Component. The component no longer pulls in the SmartObject trait, and the magic $name, $parent, and $components properties are gone. Use the explicit methods (getName(), getParent(), getComponents()) directly.
  • IComponent::NAME_SEPARATOR removed. Use IComponent::NameSeparator instead.
  • PHP 8.3 required.