APPNETOS is under active development This website and its documentation are being prepared for public launch. Content and features may change.
Select Theme
Loading

Autowire

Annotation-based property injection and lifecycle method registration for APPNETOS runtime objects.

Overview

Core\Autowire\Base resolves supported APPNETOS PHP attributes on an existing object. It injects values into annotated properties and registers annotated shutdown methods. The resolver is used as part of the APPNETOS runtime object lifecycle and is closely connected to the Core Registry.

Autowiring separates the declaration of dependencies and runtime values from the code that retrieves them. The resolver does not replace the Registry's responsibility for class resolution, object creation or shared-object management.

Context Availability

Context Independent

The shared implementation is located at appnetos/shared/src/Core/Autowire/Base.php. The resolver can be used in all implemented APPNETOS contexts. However, the availability of an annotation's value source depends on the active context: for example, HTTP request, cookie and session services must be available for the corresponding injections.

Architecture & Processing

wire() processes properties first and methods second. The resolver examines the object's class hierarchy using PHP Reflection and builds reusable annotation definitions. Supported property annotations resolve values from the Registry, runtime, configuration, environment, server, session, cookie, request, POST, GET or translations.

A property is assigned only when it is not initialized or its current value is null. Already initialized, non-null values are preserved. Method processing currently recognizes #[Shutdown] and registers the annotated method with the shutdown controller when that controller is present in the Registry.

Autowire processes annotated properties and Shutdown methods using cached reflection metadata.
Simplified runtime processing. Property injection and shutdown registration are separate paths.

Reflection Caching

The resolver maintains separate static caches for property and method reflection definitions, keyed by the concrete PHP class. The caches avoid scanning the same class hierarchy repeatedly during the current runtime. They store annotation metadata, not a permanent cache of all injected property values.

The #[Cached] property annotation is a distinct mechanism. In the current implementation, request-scope cached values are stored with a TTL; other scopes fall back to resolving the value without this request-cache shortcut. Its configuration and behavior will be described in the separate annotation documentation.

Public API Overview

Only the public API is listed here. Full signatures, parameters, return types, exceptions and DocBlocks belong to the automatically generated Developer Class Reference.

Method Description
wire() Process supported property and method annotations on an existing object.
clearReflectionCache() Clear the cached property and method reflection definitions.

Annotations

Autowire is an annotation consumer, not the definition of every APPNETOS annotation. Property injection annotations cover dependencies, configuration and runtime values, HTTP inputs, cookies, sessions and translations. The #[Cached] annotation modifies property-value resolution, while #[Shutdown] is handled as a method annotation.

Other annotations, such as #[Shared], are interpreted by different Core components. A dedicated Core Annotations documentation group will explain the annotations individually and identify their processing components.

Limitations & Extension Rules

  • Autowiring depends on services available in the active context.
  • It does not overwrite properties with an existing non-null value.
  • Shutdown registration is skipped when the shutdown controller is absent from the Registry.
  • Invalid or conflicting annotation definitions may raise annotation or reflection exceptions.
  • Core\Autowire\Base cannot be replaced through the APPNETOS Class Extension System.

Next Steps

Previous

Registry

Explore Registry

Next

EarlyFallback

Explore EarlyFallback