Go\Aop\Framework\ClassFieldAccess::ensureScopeRule PHP Method

ensureScopeRule() public method

Checks scope rules for accessing property
public ensureScopeRule ( integer $stackLevel = 2 ) : true
$stackLevel integer Stack level for check
return true if access is OK
    public function ensureScopeRule($stackLevel = 2)
    {
        $property = $this->reflectionProperty;
        if ($property->isProtected()) {
            $backTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $stackLevel + 1);
            $accessor = isset($backTrace[$stackLevel]) ? $backTrace[$stackLevel] : [];
            $propertyClass = $property->class;
            if (isset($accessor['class'])) {
                if ($accessor['class'] === $propertyClass || is_subclass_of($accessor['class'], $propertyClass)) {
                    return true;
                }
            }
            throw new AspectException("Cannot access protected property {$propertyClass}::{$property->name}");
        }
        return true;
    }