cvs: pear /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace FunctionSpacingSniff.php

From: Date: Wed, 27 Dec 2006 23:11:20 +0000
Subject: cvs: pear /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace FunctionSpacingSniff.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-43847@lists.php.net to get a copy of this message
squiz Wed Dec 27 23:11:20 2006 UTC Modified files: /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace FunctionSpacingSniff.php Log: Made error messages more friendly http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php:1.2 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php:1.3 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php:1.2 Wed Dec 27 03:39:34 2006 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php Wed Dec 27 23:11:20 2006 @@ -10,7 +10,7 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: FunctionSpacingSniff.php,v 1.2 2006/12/27 03:39:34 squiz Exp $ + * @version CVS: $Id: FunctionSpacingSniff.php,v 1.3 2006/12/27 23:11:20 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -91,11 +91,16 @@ $foundLines = 0; } else { $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextLineToken + 1), null, true); - $foundLines = $tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']; + if ($nextContent === false) { + // We are at the end of the file. + $foundLines = 0; + } else { + $foundLines = $tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']; + } } if ($foundLines !== 2) { - $phpcsFile->addError("Expected 2 blank lines after method; $foundLines line(s) found", $stackPtr); + $phpcsFile->addError("Expected 2 blank lines after function; $foundLines found", $stackPtr); } /* @@ -123,11 +128,11 @@ // Before we throw an error, check that we are not throwing an error // for another function. We don't want to error for no blank lines after - // the previous function and no blank line before this one. + // the previous function and no blank lines before this one as well. $currentLine = $tokens[$prevContent]['line']; $prevLine = ($currentLine - 1); $i = ($stackPtr - 1); - while ($currentLine != $prevLine) { + while ($currentLine != $prevLine && $currentLine > 1) { if (isset($tokens[$i]['scope_condition']) === true) { $scopeCondition = $tokens[$i]['scope_condition']; if ($tokens[$scopeCondition]['code'] === T_FUNCTION) { @@ -145,7 +150,7 @@ } if ($foundLines !== 2) { - $phpcsFile->addError("Expected 2 blank lines before method; $foundLines line(s) found", $stackPtr); + $phpcsFile->addError("Expected 2 blank lines before function; $foundLines found", $stackPtr); } }//end processTokenWithinScope()

« previous php.pear.cvs (#43847) next »