Flitch\Rule\Line\Separator::visitFile PHP Méthode

visitFile() public méthode

visitFile(): defined by FileRuleInterface.
See also: FileRuleInterface::visitFile()
public visitFile ( File $file ) : void
$file Flitch\File\File
Résultat void
    public function visitFile(File $file)
    {
        foreach ($file->getLines() as $line => $data) {
            if ($data['ending'] !== '' && $data['ending'] !== $this->eolChar) {
                $ending = str_replace(array("\r", "\n"), array('\\r', '\\n'), $data['ending']);
                $this->addViolation($file, $line, 0, sprintf('Line must end with "%s", found "%s"', $this->eolName, $ending));
            }
        }
    }

Usage Example

Exemple #1
0
 public function testOnlyAllowWindows()
 {
     $rule = new Separator();
     $rule->setEolStyle('windows');
     $rule->visitFile($this->file);
     $this->assertRuleViolations($this->file, array(array('line' => 2, 'column' => 0, 'message' => 'Line must end with "\\r\\n", found "\\r"', 'source' => 'Flitch\\Line\\Separator'), array('line' => 3, 'column' => 0, 'message' => 'Line must end with "\\r\\n", found "\\n"', 'source' => 'Flitch\\Line\\Separator')));
 }