Demo\Aspect\PropertyInterceptorAspect::aroundFieldAccess PHP Method

aroundFieldAccess() public method

Advice that controls an access to the properties
public aroundFieldAccess ( Go\Aop\Intercept\FieldAccess $fieldAccess ) : mixed
$fieldAccess Go\Aop\Intercept\FieldAccess Joinpoint
return mixed
    public function aroundFieldAccess(FieldAccess $fieldAccess)
    {
        $isRead = $fieldAccess->getAccessType() == FieldAccess::READ;
        // proceed all internal advices
        $fieldAccess->proceed();
        if ($isRead) {
            // if you want to change original property value, then return it by reference
            $value = $fieldAccess->getValue();
        } else {
            // if you want to change value to set, then return it by reference
            $value = $fieldAccess->getValueToSet();
        }
        echo "Calling After Interceptor for ", $fieldAccess, ", value: ", json_encode($value), PHP_EOL;
    }
PropertyInterceptorAspect