public int canAccess(Environment env, ClassEntity context) {
        switch (modifier){
            case PUBLIC: return 0;
            case PRIVATE:
                ClassEntity cl = context == null ? env.getLastClassOnStack() : context;
                if (cl == null)
                    return 2;

                if (cl.getId() == this.clazz.getId())
                    return 0;

                MethodEntity tmp = prototype;
                while (tmp != null){
                    if (cl.getId() == tmp.clazz.getId())
                        return 0;
                    tmp = tmp.prototype;
                }
                return 2;
            case PROTECTED:
                ClassEntity originClass;
                ClassEntity clazz = originClass = context == null ? env.getLateStaticClass() : context;
                if (clazz == null)
                    return 1;

                long id = this.clazz.getId();
                do {
                    if (clazz.getId() == id)
                        return 0;
                    clazz = clazz.parent;
                } while (clazz != null);

                if (this.clazz.isInstanceOf(originClass)) {
                    return 0;
                }

                return 1;
        }
        return 2;
    }
0 - success
1 - invalid protected
2 - invalid private
@param env
@return
jphp-runtime/src/php/runtime/reflection/MethodEntity.java