trait InteractsWithAop

Provides a test helper for invoking a method through the AOP pipeline without relying on generated proxies.

In full application or Testbench integration tests, AOP proxies may already be generated and those tests should call the target method normally. This trait is for tests where the target is not already proxied, or where the goal is to exercise aspect pipeline behavior directly.

callWithAspects() invokes the same dispatcher used by generated proxies before calling the original method via reflection.

Methods

bool
isAopProxied(object $instance)

Determine if the given instance is already running through an AOP proxy.

mixed
callWithAspects(object $instance, string $method, array $arguments = [])

Call a method through the registered AOP aspect pipeline.

Details

at line 34
protected bool isAopProxied(object $instance)

Determine if the given instance is already running through an AOP proxy.

Call generated proxies normally. Use callWithAspects() only for focused tests that register aspects directly without generating proxies; it does not bypass bootstrap's rejection of targets loaded before generation.

Parameters

object $instance

Return Value

bool

at line 54
protected mixed callWithAspects(object $instance, string $method, array $arguments = [])

Call a method through the registered AOP aspect pipeline.

Builds a ProceedingJoinPoint for the given instance and method, resolves matching aspects from AspectCollector, and executes them in priority order. The original method is called via reflection at the end of the pipeline. The instance must not already be proxied.

After application bootstrap, call {\Hypervel\Di\Aop\AspectCollector::unseal()} before registering aspects for this helper.

Parameters

object $instance

The object instance to call the method on

string $method

The method name to intercept

array $arguments

Method arguments as key => value pairs (parameter names as keys)

Return Value

mixed