Commit: fd0759ddbf6eb1a390a4bef5d5530f67ba04efdd
Author: David Persson | Date: 2009-12-02 20:25:03 +0100
diff --git a/config/phpca_lithium_standard.ini b/config/phpca_lithium_standard.ini
index 501ebb3..29ddb59 100644
--- a/config/phpca_lithium_standard.ini
+++ b/config/phpca_lithium_standard.ini
@@ -11,6 +11,7 @@ additional_rules= extensions/phpca/Rule
[OpenTagAtBeginningRule]
[CloseTagAtEndRule]
[EmptyLineBeforeCloseTagRule]
+[NoEmptyLineBeforeClassCloseRule]
[IncludeAndRequireWithoutBracketsRule]
[KeywordsAreLowercaseRule]
[NoVarKeywordsRule]
diff --git a/extensions/phpca/Rule/NoEmptyLineBeforeClassCloseRule.php b/extensions/phpca/Rule/NoEmptyLineBeforeClassCloseRule.php
new file mode 100644
index 0000000..594f22c
--- /dev/null
+++ b/extensions/phpca/Rule/NoEmptyLineBeforeClassCloseRule.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace spriebsch\PHPca\Rule;
+
+/**
+ * Ensures that there are no empty lines before the closing curly brace of a class.
+ */
+class NoEmptyLineBeforeClassCloseRule extends Rule
+{
+ /**
+ * Performs the rule check.
+ *
+ * @returns null
+ */
+ protected function doCheck()
+ {
+ while ($this->file->seekTokenId(T_CLASS)) {
+ $this->file->seekTokenId(T_OPEN_CURLY);
+ $rewind = $this->file->current();
+ $this->file->seekMatchingCurlyBrace($rewind);
+ $this->file->prev();
+
+ $token = $this->file->current();
+ $lineEndings = $this->configuration->getLineEndings();
+
+ if (addcslashes($token->getText(), "\0..\37") == $lineEndings . $lineEndings) {
+ $this->addViolation('Empty line before class closing curly brace', $token);
+ }
+
+ $this->file->seekToken($rewind);
+ $this->file->next();
+ }
+ }
+}
+?>
\ No newline at end of file