Flitch\Rule\Whitespace\DisallowTabulators::visitToken PHP Méthode

visitToken() public méthode

visitToken(): defined by TokenRuleInterface.
See also: TokenRuleInterface::visitToken()
public visitToken ( File $file ) : void
$file Flitch\File\File
Résultat void
    public function visitToken(File $file)
    {
        $token = $file->current();
        if (false !== strpos($token->getLexeme(), "\t")) {
            $this->addViolation($file, $token->getLine(), $token->getColumn(), 'Tabulator found');
        }
    }

Usage Example

 public function testTabulators()
 {
     $tokenizer = new Tokenizer();
     $file = $tokenizer->tokenize('foo.php', "<?php\n\t");
     $file->rewind();
     $file->seekTokenType(T_WHITESPACE);
     $rule = new DisallowTabulators();
     $rule->visitToken($file);
     $this->assertRuleViolations($file, array(array('line' => 2, 'column' => 1, 'message' => 'Tabulator found', 'source' => 'Flitch\\Whitespace\\DisallowTabulators')));
 }