/**
* visitFile(): defined by FileRuleInterface.
*
* @see FileRuleInterface::visitFile()
* @param File $file
* @return void
*/
public function visitFile(File $file)
{
$source = $file->getSource();
if (@iconv($this->encoding, $this->encoding, $source) !== $source) {
$this->addViolation($file, 0, 0, sprintf('File is not encoded in "%s"', $this->encoding));
return;
}
if (!$this->allowBom && isset(self::$byteOrderMarks[$this->encoding])) {
$bom = self::$byteOrderMarks[$this->encoding];
if (substr($source, 0, strlen($bom)) === $bom) {
$this->addViolation($file, 0, 0, sprintf('File starts with a BOM', $this->encoding));
}
}
}