Flitch\Rule\Whitespace\Indentation::check PHP Метод

check() публичный Метод

check(): defined by Rule interface.
См. также: Rule::check()
public check ( File $file ) : void
$file Flitch\File\File
Результат void
    public function check(File $file)
    {
        $indentation = str_repeat($this->indentStyle === 'space' ? ' ' : "\t", $this->indentCount);
        $file->rewind();
        while (true) {
            $token = $file->current();
            $level = $token->getLevel();
            $file->next();
            if ($file->current()->getType() === '}' || $file->current()->getType() === ')') {
                $level--;
            }
            $file->prev();
            $expectedIndentation = str_repeat($indentation, $level);
            $actualIndentation = $token->getTrailingWhitespace();
            if ($expectedIndentation !== $actualIndentation) {
                $this->addViolation($file, $token, $column, $message);
            }
            if (!$file->seekNextLine()) {
                return;
            }
        }
    }