Skip to content

[Bug] initialization pointcut makes other advices not bound to target #425

Description

@l00k
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions