HippoPHP\Hippo\Checks\Style\VariableVariableCheck::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();
        try {
            do {
                // Jump us to the next token we want to check.
                $tokens->seekToType(T_VARIABLE);
                $token = $tokens->current();
                // If the content !== $ then go back a token, is that $?
                if ($token->getContent() !== '$') {
                    $prevTokenList = clone $tokens;
                    $prevToken = $prevTokenList->prev()->current();
                    if ($prevToken->getContent() === '$') {
                        $this->addViolation($file, $token->getLine(), $token->getColumn(), 'Do not use variable variables.', Violation::SEVERITY_ERROR);
                    }
                }
            } while ($tokens->valid());
        } catch (\HippoPHP\Tokenizer\Exception\OutOfBoundsException $e) {
            // Ignore the exception, we're at the end of the file.
        }
    }