cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting MultipleStatementAlignmentSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting MultipleStatementAlignmentUnitTest.inc MultipleStatementAlignmentUnitTest.php
| From: | Greg Sherwood | Date: | Wed, 14 Feb 2007 22:33:35 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting MultipleStatementAlignmentSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting MultipleStatementAlignmentUnitTest.inc MultipleStatementAlignmentUnitTest.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44663@lists.php.net to get a copy of this message | ||
squiz Wed Feb 14 22:33:35 2007 UTC
Modified files:
/pear/PHP_CodeSniffer package.xml
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting
MultipleStatementAlignmentSniff.php
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting
MultipleStatementAlignmentUnitTest.inc
MultipleStatementAlignmentUnitTest.php
Log:
Fixed missing error when multiple statements are not aligned correctly with object operators
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.30&r2=1.31&diff_format=u
Index: pear/PHP_CodeSniffer/package.xml
diff -u pear/PHP_CodeSniffer/package.xml:1.30 pear/PHP_CodeSniffer/package.xml:1.31
--- pear/PHP_CodeSniffer/package.xml:1.30 Mon Feb 12 23:23:47 2007
+++ pear/PHP_CodeSniffer/package.xml Wed Feb 14 22:33:34 2007
@@ -39,6 +39,7 @@
- Squiz FunctionSpacingSniff now reports incorrect lines below function on closing brace, not
function keyword
- Squiz FileCommentSniff now checks that there are no blank lines between the open PHP tag and
the comment
- Fixed incorrect error with switch closing brace in Squiz SwitchDeclarationSniff
+ - Fixed missing error when multiple statements are not aligned correctly with object operators
- Fixed bug #9844 : throw new Exception(\n accidently reported as error but it ain't
</notes>
<contents>
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php?r1=1.5&r2=1.6&diff_format=u
Index:
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php:1.5
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php:1.6
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php:1.5 Thu
Jan 11 01:06:42 2007
+++
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php Wed
Feb 14 22:33:35 2007
@@ -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: MultipleStatementAlignmentSniff.php,v 1.5 2007/01/11 01:06:42 squiz Exp $
+ * @version CVS: $Id: MultipleStatementAlignmentSniff.php,v 1.6 2007/02/14 22:33:35 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -201,17 +201,26 @@
*/
private function _isAssignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
- $tokens = $phpcsFile->getTokens();
if ($stackPtr === false) {
return false;
}
- // If there is something other than whitespace on this line before this variable, its not
what we want.
+ $tokens = $phpcsFile->getTokens();
+
+ // If there is something other than whitespace on this line before this
+ // variable, its not what we want.
$prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr
- 1), null, true);
if ($tokens[$prevContent]['line'] === $tokens[$stackPtr]['line']) {
return false;
}
+ // If this variable is followed by an object operator, we need to skip
+ // the member var component.
+ $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true);
+ if ($tokens[$nextContent]['code'] === T_OBJECT_OPERATOR) {
+ $stackPtr = $phpcsFile->findNext(array(T_WHITESPACE), ($nextContent + 1), null,
true);
+ }
+
$nextContent = $phpcsFile->findNext(array(T_VARIABLE, T_OPEN_SQUARE_BRACKET,
T_CLOSE_SQUARE_BRACKET, T_CONSTANT_ENCAPSED_STRING, T_LNUMBER), ($stackPtr + 1), null, true);
$nextContent++;
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc?r1=1.3&r2=1.4&diff_format=u
Index:
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc:1.3
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc:1.4
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc:1.3 Thu
Jan 11 01:06:42 2007
+++
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc Wed
Feb 14 22:33:35 2007
@@ -73,4 +73,8 @@
$commentStart = $phpcsFile->findPrevious();
$commentEnd = $this->_phpcsFile;
$expected .= '...';
+
+// Invalid
+$this->okButton = new Button();
+$content = new MyClass();
?>
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php?r1=1.3&r2=1.4&diff_format=u
Index:
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php:1.3
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php:1.4
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php:1.3 Fri
Dec 29 05:47:41 2006
+++
pear/PHP_CodeSniffer/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php Wed
Feb 14 22:33:35 2007
@@ -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: MultipleStatementAlignmentUnitTest.php,v 1.3 2006/12/29 05:47:41 squiz Exp
$
+ * @version CVS: $Id: MultipleStatementAlignmentUnitTest.php,v 1.4 2007/02/14 22:33:35 squiz Exp
$
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -74,6 +74,8 @@
64 => 1,
65 => 1,
71 => 1,
+ 78 => 1,
+ 79 => 1,
);
}//end getWarningList()