HippoPHP\Hippo\Checks\Whitespace\IndentationCheck::checkFileInternal PHP Метод

checkFileInternal() защищенный Метод

checkFileInternal(): defined by AbstractCheck.
См. также: 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();
        $this->setIndentStyle($config->get('style', $this->indentStyle));
        $this->setIndentCount($config->get('count', $this->indentCount));
        $indentation = $this->getBaseIndentation();
        $lines = $this->getLines($checkContext->getTokenList());
        $level = 0;
        foreach ($lines as $lineNumber => $line) {
            $actualIndentation = '';
            if (count($line) > 0) {
                if ($line[0]->isType(T_WHITESPACE)) {
                    $actualIndentation = $line[0]->getContent();
                }
            }
            foreach ($line as $token) {
                $content = $token->getContent();
                if ($content === '}' || $content === ')' || $content === ']') {
                    $level--;
                }
            }
            $expectedIndentation = $level > 0 ? str_repeat($indentation, $level) : '';
            if ($expectedIndentation !== $actualIndentation) {
                $this->addViolation($file, $lineNumber, count($line) > 0 ? $line[0]->getColumn() + strlen($line[0]->getContent()) : 1, sprintf('Unexpected indentation (expected: %s, actual: %s)', $this->escape($expectedIndentation), $this->escape($actualIndentation)), Violation::SEVERITY_WARNING);
            }
            foreach ($line as $token) {
                $content = $token->getContent();
                if ($content === '{' || $content === '(' || $content === '[') {
                    $level++;
                }
            }
        }
    }