Commit: 0d194a4e98e2c392138cc08ac12372bf659e9b6e

Author: David Persson | Date: 2009-12-03 15:10:00 +0100
Adding `NoEolAtEofRule`.
diff --git a/config/phpca_lithium_standard.ini b/config/phpca_lithium_standard.ini index 3dfaf07..86ae7d6 100644 --- a/config/phpca_lithium_standard.ini +++ b/config/phpca_lithium_standard.ini @@ -26,6 +26,7 @@ additional_rules= extensions/phpca/Rule [NoShutupOperatorsRule] ; [MethodsMustHaveVisibilityOperatorRule] [OneClassPerFileRule] +[NoEolAtEofRule] [MaximumLineLengthRule] line_length = 100 diff --git a/extensions/phpca/Rule/NoEolAtEofRule.php b/extensions/phpca/Rule/NoEolAtEofRule.php new file mode 100644 index 0000000..8122b0d --- /dev/null +++ b/extensions/phpca/Rule/NoEolAtEofRule.php @@ -0,0 +1,30 @@ +<?php + +namespace spriebsch\PHPca\Rule; + +use spriebsch\PHPca\Token; + +/** + * Ensures there is no EOL marker at the EOF. + */ +class NoEolAtEofRule extends Rule +{ + /** + * Performs the rule check. + * + * @returns null + */ + protected function doCheck() + { + $content = $this->file->getSourceCode(); + $eol = stripcslashes($this->configuration->getLineEndings()); + $eof = substr($content, - strlen($eol)); + + if ($eof == $eol) { + $line = substr_count($content, $eol); + $token = new Token(T_WHITESPACE, $eof, $line - 1); + $this->addViolation('EOL at EOF', $token); + } + } +} +?> \ No newline at end of file