class MonitorAspect
implements Aspect
{
/**
* @Before("execution(public App\Example->*(*))")
*/
public function beforeMethodExecution(MethodInvocation $invocation)
{
$obj = $invocation->getThis();
echo 'BEFORE: ',
is_object($obj) ? get_class($obj) : $obj,
$invocation->getMethod()->isStatic() ? '::' : '->',
$invocation->getMethod()->getName(),
'()',
' with arguments: ',
json_encode($invocation->getArguments()),
PHP_EOL;
}
(... other pointcuts)
/**
* @After("initialization(App\Example)")
*/
public function initialization(ReflectionConstructorInvocation $invocation)
{
$obj = $invocation->getThis();
echo 'INIT: ',
get_class($invocation->getThis()),
PHP_EOL;
}
}
If I add initialization pointcut to aspect it makes only this one executed.
Also class is changed to App\Example__AopProxied (normally in methodInvocation I get App\Example).
For staticinitialization it works ok - nothing wrong happens. But If I add initialization targeting same class as other advices it makes all those advices stop working - only initialization is executed.
If I add
initializationpointcut to aspect it makes only this one executed.Also class is changed to
App\Example__AopProxied(normally in methodInvocation I getApp\Example).For
staticinitializationit works ok - nothing wrong happens. But If I addinitializationtargeting same class as other advices it makes all those advices stop working - only initialization is executed.