HippoPHP\Hippo\Checks\Naming\QuoteStyleCheck::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->setQuoteStyle($config->get('style', $this->style));
        try {
            do {
                // Jump us to the next token we want to check.
                $tokens->seekToType(T_CONSTANT_ENCAPSED_STRING);
                $token = $tokens->current();
                if ($this->isBadStyle($token)) {
                    // Work out what style we shouldn't be using.
                    $styles = $this->styles;
                    unset($styles[$this->style]);
                    $badStyle = array_keys($styles)[0];
                    $this->addViolation($file, $token->getLine(), $token->getColumn(), sprintf('Prefer %s quotes to %s', addslashes($this->style), $badStyle), Violation::SEVERITY_INFO);
                }
            } while ($tokens->valid());
        } catch (\HippoPHP\Tokenizer\Exception\OutOfBoundsException $e) {
            // Ignore the exception, we're at the end of the file.
        }
    }