public visitToken ( |
||
$file | ||
return | void |
public function visitToken(File $file)
{
if (!$file->seekTokenType(T_STRING, false, '(')) {
return;
}
$token = $file->current();
if (!in_array($token->getLexeme(), self::$magicMethods) && !preg_match('(^' . $this->format . '$)', $token->getLexeme())) {
$this->addViolation($file, $token->getLine(), $token->getColumn(), sprintf('Method name does not match format "%s"', $this->format));
}
}
public function testNoViolationOnClosures() { $tokenizer = new Tokenizer(); $file = $tokenizer->tokenize('foo.php', "<?php function() {}; class foo {}"); $file->rewind(); $file->seekTokenType(T_FUNCTION); $rule = new Methods(); $rule->setFormat('bar'); $rule->visitToken($file); $this->assertRuleViolations($file, array()); }