public function visitFile(File $file)
{
foreach ($file->getLines() as $line => $data) {
$lineLength = iconv_strlen(str_replace("\t", str_repeat(' ', $this->tabExpand), $data['content']), $file->getEncoding());
$violationLimit = null;
$severity = null;
if ($this->errorLimit !== null && $lineLength > $this->errorLimit) {
$violationLimit = $this->errorLimit;
$severity = Violation::SEVERITY_ERROR;
} elseif ($this->warningLimit !== null && $lineLength > $this->warningLimit) {
$violationLimit = $this->warningLimit;
$severity = Violation::SEVERITY_WARNING;
} elseif ($this->infoLimit !== null && $lineLength > $this->infoLimit) {
$violationLimit = $this->infoLimit;
$severity = Violation::SEVERITY_INFO;
}
if ($violationLimit !== null) {
$this->addViolation($file, $line, 0, sprintf('Line is longer than %d characters', $violationLimit), $severity);
}
}
}