HippoPHP\Hippo\Checks\Naming\PrivateVariableNamingCheck::checkFileInternal PHP Method

checkFileInternal() protected method

checkFileInternal(): defined by AbstractCheck.
See also: AbstractCheck::checkFileInternal()
protected checkFileInternal ( CheckContext $checkContext, Config $config )
$checkContext HippoPHP\Hippo\CheckContext
$config HippoPHP\Hippo\Config\Config
    protected function checkFileInternal(CheckContext $checkContext, Config $config)
    {
        $file = $checkContext->getFile();
        $tokens = $checkContext->getTokenList();
        $this->setPattern($config->get('pattern', $this->pattern));
        try {
            do {
                // Jump us to the next token we want to check.
                $tokens->seekToType(T_PRIVATE)->skipToNextNonWhitespace();
                $token = $tokens->current();
                if ($token->isType(T_VARIABLE)) {
                    if (!preg_match($this->pattern, $token->getContent())) {
                        $this->addViolation($file, $token->getLine(), $token->getColumn(), sprintf('Private variable `%s` should follow a `%s` pattern', $token->getContent(), addslashes($this->pattern)), Violation::SEVERITY_ERROR);
                    }
                }
            } while ($tokens->valid());
        } catch (\HippoPHP\Tokenizer\Exception\OutOfBoundsException $e) {
            // Ignore the exception, we're at the end of the file.
        }
    }