Zephir\ClassMethod::checkVisibility PHP Method

checkVisibility() public method

Checks for visibility congruence
public checkVisibility ( array $visibility, string $name, array $original = null )
$visibility array
$name string
$original array
    public function checkVisibility(array $visibility, $name, array $original = null)
    {
        if (count($visibility) > 1) {
            if (in_array('public', $visibility) && in_array('protected', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'public' and 'protected' at the same time", $original);
            }
            if (in_array('public', $visibility) && in_array('private', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'public' and 'private' at the same time", $original);
            }
            if (in_array('private', $visibility) && in_array('protected', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'protected' and 'private' at the same time", $original);
            }
            if (in_array('private', $visibility) && in_array('internal', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'internal' and 'private' at the same time", $original);
            }
            if (in_array('protected', $visibility) && in_array('internal', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'internal' and 'protected' at the same time", $original);
            }
            if (in_array('public', $visibility) && in_array('internal', $visibility)) {
                throw new CompilerException("Method '{$name}' cannot be 'internal' and 'public' at the same time", $original);
            }
        }
        if ($name == '__construct') {
            if (in_array('static', $visibility)) {
                throw new CompilerException("Constructors cannot be 'static'", $original);
            }
        } else {
            if ($name == '__destruct') {
                if (in_array('static', $visibility)) {
                    throw new CompilerException("Destructors cannot be 'static'", $original);
                }
            }
        }
        if (is_array($visibility)) {
            $this->isAbstract = in_array('abstract', $visibility);
            $this->isStatic = in_array('static', $visibility);
            $this->isFinal = in_array('final', $visibility);
            $this->isPublic = in_array('public', $visibility);
            $this->isInternal = in_array('internal', $visibility);
        }
    }