/** * check(): defined by Rule interface. * * @see Rule::check() * @param File $file * @return 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; } } }