cvs: pear /PHP_CodeSniffer CodeSniffer.php package.xml /PHP_CodeSniffer/CodeSniffer File.php /PHP_CodeSniffer/tests/Standards
AbstractSniffUnitTest.php
| From: | Greg Sherwood | Date: | Sun, 22 Apr 2007 04:32:33 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer CodeSniffer.php package.xml /PHP_CodeSniffer/CodeSniffer File.php /PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-46095@lists.php.net to get a copy of this message | ||
squiz Sun Apr 22 04:32:33 2007 UTC
Modified files:
/pear/PHP_CodeSniffer CodeSniffer.php package.xml
/pear/PHP_CodeSniffer/CodeSniffer File.php
/pear/PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php
Log:
Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request
#10761)
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer.php?r1=1.24&r2=1.25&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer.php diff -u pear/PHP_CodeSniffer/CodeSniffer.php:1.24 pear/PHP_CodeSniffer/CodeSniffer.php:1.25 --- pear/PHP_CodeSniffer/CodeSniffer.php:1.24 Sat Apr 21 01:51:00 2007 +++ pear/PHP_CodeSniffer/CodeSniffer.php Sun Apr 22 04:32:33 2007 @@ -11,7 +11,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: CodeSniffer.php,v 1.24 2007/04/21 01:51:00 squiz Exp $ + * @version CVS: $Id: CodeSniffer.php,v 1.25 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -173,7 +173,7 @@ $this->_registerTokenListeners($standard, $sniffs); if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo "DONE\n"; + echo 'DONE'.PHP_EOL; } foreach ($files as $file) { @@ -374,7 +374,7 @@ $startTime = time(); echo 'Processing '.basename($file).' '; if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\n"; + echo PHP_EOL; } } @@ -385,11 +385,11 @@ if (PHP_CODESNIFFER_VERBOSITY > 0) { $timeTaken = (time() - $startTime); if ($timeTaken === 0) { - echo "DONE in < 1 second\n"; + echo 'DONE in < 1 second'.PHP_EOL; } else if ($timeTaken === 1) { - echo "DONE in 1 second\n"; + echo 'DONE in 1 second'.PHP_EOL; } else { - echo "DONE in $timeTaken seconds\n"; + echo "DONE in $timeTaken seconds".PHP_EOL; } } @@ -457,15 +457,15 @@ ksort($errors); - echo "\nFILE: "; + echo PHP_EOL.'FILE: '; if (strlen($filename) <= 71) { echo $filename; } else { echo '...'.substr($filename, (strlen($filename) - 71)); } - echo "\n"; - echo str_repeat('-', 80)."\n"; + echo PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; $numLines = count($errors); echo "FOUND $numErrors ERROR(S) "; @@ -473,8 +473,8 @@ echo "AND $numWarnings WARNING(S) "; } - echo "AFFECTING $numLines LINE(S)\n"; - echo str_repeat('-', 80)."\n"; + echo "AFFECTING $numLines LINE(S)".PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; // Work out the max line number for formatting. $maxLine = 0; @@ -507,7 +507,7 @@ foreach ($lineErrors as $error) { // The padding that goes on the front of the line. $padding = ($maxLineLength - strlen($line)); - $errorMsg = wordwrap($error['message'], $maxErrorSpace, "\n$paddingLine2"); + $errorMsg = wordwrap($error['message'], $maxErrorSpace, PHP_EOL."$paddingLine2"); echo ' '.str_repeat(' ', $padding).$line.' | '.$error['type']; if ($error['type'] === 'ERROR') { @@ -516,11 +516,11 @@ } } - echo ' | '.$errorMsg."\n"; + echo ' | '.$errorMsg.PHP_EOL; } }//end foreach - echo str_repeat('-', 80)."\n\n"; + echo str_repeat('-', 80).PHP_EOL.PHP_EOL; }//end foreach @@ -562,15 +562,15 @@ return; } - echo "\nPHP CODE SNIFFER REPORT SUMMARY\n"; - echo str_repeat('-', 80)."\n"; + echo PHP_EOL.'PHP CODE SNIFFER REPORT SUMMARY'.PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; if ($showWarnings === true) { - echo 'FILE'.str_repeat(' ', 60)."ERRORS WARNINGS\n"; + echo 'FILE'.str_repeat(' ', 60).'ERRORS WARNINGS'.PHP_EOL; } else { - echo 'FILE'.str_repeat(' ', 70)."ERRORS\n"; + echo 'FILE'.str_repeat(' ', 70).'ERRORS'.PHP_EOL; } - echo str_repeat('-', 80)."\n"; + echo str_repeat('-', 80).PHP_EOL; $totalErrors = 0; $totalWarnings = 0; @@ -595,21 +595,21 @@ echo $errors['warnings']; } - echo "\n"; + echo PHP_EOL; $totalErrors += $errors['errors']; $totalWarnings += $errors['warnings']; $totalFiles++; }//end foreach - echo str_repeat('-', 80)."\n"; + echo str_repeat('-', 80).PHP_EOL; echo "A TOTAL OF $totalErrors ERROR(S) "; if ($showWarnings === true) { echo "AND $totalWarnings WARNING(S) "; } - echo "WERE FOUND IN $totalFiles FILE(S)\n"; - echo str_repeat('-', 80)."\n\n"; + echo "WERE FOUND IN $totalFiles FILE(S)".PHP_EOL; + echo str_repeat('-', 80).PHP_EOL.PHP_EOL; }//end printErrorReportSummary() http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.55&r2=1.56&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.55 pear/PHP_CodeSniffer/package.xml:1.56 --- pear/PHP_CodeSniffer/package.xml:1.55 Sat Apr 21 01:51:00 2007 +++ pear/PHP_CodeSniffer/package.xml Sun Apr 22 04:32:33 2007 @@ -35,6 +35,8 @@ - Fixed variable name error causing incorrect error message in Squiz ValidVariableNameSniff - Fixed bugs #10751, #10777 : Sniffer class paths handled incorrectly in Windows - Thanks to Carsten Wiedmann for the patch. + - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) + - Thanks to Carsten Wiedmann for the patch. </notes> <contents> <dir name="/"> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/File.php?r1=1.22&r2=1.23&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/File.php diff -u pear/PHP_CodeSniffer/CodeSniffer/File.php:1.22 pear/PHP_CodeSniffer/CodeSniffer/File.php:1.23 --- pear/PHP_CodeSniffer/CodeSniffer/File.php:1.22 Thu Mar 8 06:09:56 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/File.php Sun Apr 22 04:32:33 2007 @@ -11,7 +11,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: File.php,v 1.22 2007/03/08 06:09:56 squiz Exp $ + * @version CVS: $Id: File.php,v 1.23 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -411,7 +411,7 @@ public function start() { if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** START TOKEN PROCESSING ***\n"; + echo "\t*** START TOKEN PROCESSING ***".PHP_EOL; } // Foreach of the listeners that have registed to listen for this @@ -420,7 +420,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 2) { $type = $token['type']; $content = str_replace("\n", '\n', $token['content']); - echo "\t\tProcess token $stackPtr: $type => $content\n"; + echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL; } $tokenType = $token['code']; @@ -435,14 +435,14 @@ if (PHP_CODESNIFFER_VERBOSITY > 2) { $timeTaken = round((microtime(true) - $startTime), 4); - echo "DONE in $timeTaken seconds\n"; + echo "DONE in $timeTaken seconds".PHP_EOL; } } } }//end foreach if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** END TOKEN PROCESSING ***\n"; + echo "\t*** END TOKEN PROCESSING ***".PHP_EOL; } // We don't need the tokens any more, so get rid of them @@ -580,6 +580,9 @@ $numTokens = count($this->_tokens); $numLines = $this->_tokens[($numTokens - 1)]['line']; echo "[$numTokens tokens in $numLines lines]... "; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo PHP_EOL; + } } }//end _parse() @@ -828,7 +831,7 @@ private function _createScopeMap() { if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START SCOPE MAP ***\n"; + echo "\t*** START SCOPE MAP ***".PHP_EOL; } $numTokens = count($this->_tokens); @@ -838,7 +841,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$i]['type']; $content = str_replace("\n", '\n', $this->_tokens[$i]['content']); - echo "\tStart scope map at $i: $type => $content\n"; + echo "\tStart scope map at $i: $type => $content".PHP_EOL; } $i = $this->_recurseScopeMap($i); @@ -846,7 +849,7 @@ } if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END SCOPE MAP ***\n"; + echo "\t*** END SCOPE MAP ***".PHP_EOL; } }//end _createScopeMap() @@ -893,14 +896,14 @@ echo 'ignore;'; } - echo "]: $type => $content\n"; + echo "]: $type => $content".PHP_EOL; } // Is this an opening condition ? if (isset(self::$_scopeOpeners[$tokenType]) === true) { if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* token is an opening condition *\n"; + echo '* token is an opening condition *'.PHP_EOL; } $isShared = (self::$_scopeOpeners[$tokenType]['shared'] === true); @@ -909,7 +912,7 @@ // We've been here before. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* already processed, skipping *\n"; + echo '* already processed, skipping *'.PHP_EOL; } if ($isShared === false && isset($this->_tokens[$i]['scope_closer']) === true) { @@ -923,14 +926,14 @@ // share openers, so we will never find one. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* it was another token's opener, bailing *\n"; + echo '* it was another token\'s opener, bailing *'.PHP_EOL; } return $stackPtr; } else { if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* searching for closer *\n"; + echo '* searching for closer *'.PHP_EOL; } $i = $this->_recurseScopeMap($i, ($depth + 1)); @@ -942,7 +945,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found scope opener for $stackPtr ($type)\n"; + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; } $opener = $i; @@ -952,7 +955,7 @@ // offset or alike, so let's ignore it. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* finished ignoring curly brace *\n"; + echo '* finished ignoring curly brace *'.PHP_EOL; } $ignore = false; @@ -960,7 +963,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found scope closer for $stackPtr ($type)\n"; + echo "=> Found scope closer for $stackPtr ($type)".PHP_EOL; } foreach (array($stackPtr, $opener, $i) as $token) { @@ -998,7 +1001,7 @@ // map. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* ignoring curly brace *\n"; + echo '* ignoring curly brace *'.PHP_EOL; } $ignore = true; @@ -1009,7 +1012,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Couldn't find scope opener for $stackPtr ($type), bailing\n"; + echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; } return $stackPtr; @@ -1020,7 +1023,7 @@ // We found the end token for the opener we were ignoring. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* finished ignoring curly brace *\n"; + echo '* finished ignoring curly brace *'.PHP_EOL; } $ignore = false; @@ -1032,7 +1035,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found (unexpected) scope closer for $stackPtr ($type)\n"; + echo "=> Found (unexpected) scope closer for $stackPtr ($type)".PHP_EOL; } foreach (array($stackPtr, $opener) as $token) { @@ -1065,7 +1068,7 @@ private function _createLevelMap() { if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START LEVEL MAP ***\n"; + echo "\t*** START LEVEL MAP ***".PHP_EOL; } $numTokens = count($this->_tokens); @@ -1091,7 +1094,7 @@ echo rtrim($condString, ',').';'; } - echo "]: $type => $content\n"; + echo "]: $type => $content".PHP_EOL; } $this->_tokens[$i]['level'] = $level; @@ -1105,7 +1108,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", ($level + 1)); - echo "=> Found scope opener for $stackPtr ($type)\n"; + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; } $stackPtr = $this->_tokens[$i]['scope_condition']; @@ -1128,7 +1131,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$badToken]['type']; echo str_repeat("\t", ($level + 1)); - echo "* shared closer, cleaning up $badToken ($type) *\n"; + echo "* shared closer, cleaning up $badToken ($type) *".PHP_EOL; } for ($x = $this->_tokens[$i]['scope_condition']; $x <= $i; $x++) { @@ -1154,11 +1157,11 @@ $newLevel = $this->_tokens[$x]['level']; echo str_repeat("\t", ($level + 1)); - echo "* cleaned $x ($type) *\n"; + echo "* cleaned $x ($type) *".PHP_EOL; echo str_repeat("\t", ($level + 2)); - echo "=> level changed from $oldLevel to $newLevel\n"; + echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; echo str_repeat("\t", ($level + 2)); - echo "=> conditions changed from $oldConds to $newConds\n"; + echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; }//end if }//end for @@ -1166,7 +1169,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$badToken]['type']; echo str_repeat("\t", ($level + 1)); - echo "* token $badToken ($type) removed from conditions array *\n"; + echo "* token $badToken ($type) removed from conditions array *".PHP_EOL; } unset ($openers[$lastOpener]); @@ -1174,7 +1177,7 @@ $level--; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 2)); - echo "* level decreased *\n"; + echo '* level decreased *'.PHP_EOL; } }//end if }//end if @@ -1182,14 +1185,14 @@ $level++; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 1)); - echo "* level increased *\n"; + echo '* level increased *'.PHP_EOL; } $conditions[$stackPtr] = $this->_tokens[$stackPtr]['code']; if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", ($level + 1)); - echo "* token $stackPtr ($type) added to conditions array *\n"; + echo "* token $stackPtr ($type) added to conditions array *".PHP_EOL; } $lastOpener = $this->_tokens[$i]['scope_opener']; @@ -1212,20 +1215,20 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$oldOpener]['type']; echo str_repeat("\t", ($level + 1)); - echo "=> Found scope closer for $oldOpener ($type)\n"; + echo "=> Found scope closer for $oldOpener ($type)".PHP_EOL; } if ($removedCondition === false) { $oldCondition = array_pop($conditions); if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 1)); - echo '* token '.token_name($oldCondition)." removed from conditions array *\n"; + echo '* token '.token_name($oldCondition)." removed from conditions array *".PHP_EOL; } $level--; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 2)); - echo "* level decreased *\n"; + echo '* level decreased *'.PHP_EOL; } } @@ -1238,7 +1241,7 @@ }//end for if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END LEVEL MAP ***\n"; + echo "\t*** END LEVEL MAP ***".PHP_EOL; } }//end _createLevelMap() http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?r1=1.4&r2=1.5&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php diff -u pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.5 --- pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 Fri Dec 29 00:05:45 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php Sun Apr 22 04:32:33 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: AbstractSniffUnitTest.php,v 1.4 2006/12/29 00:05:45 squiz Exp $ + * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.5 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -198,7 +198,7 @@ $foundMessage .= "$numErrors error(s)"; if ($numErrors !== 0) { $foundString .= 'error(s)'; - $errors .= implode("\n -> ", $problems['found_errors']); + $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); } if ($expectedWarnings !== $numWarnings) { @@ -217,13 +217,13 @@ $foundMessage .= "$numWarnings warning(s)"; if ($numWarnings !== 0) { $foundString .= 'warning(s)'; - $errors .= implode("\n -> ", $problems['found_warnings']); + $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); } } $fullMessage = "$lineMessage $expectedMessage $foundMessage."; if ($errors !== '') { - $fullMessage .= " The $foundString found were:\n -> $errors"; + $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; } $failureMessages[] = $fullMessage; @@ -231,7 +231,7 @@ }//end foreach if (empty($failureMessages) === false) { - $this->fail(implode("\n", $failureMessages)); + $this->fail(implode(PHP_EOL, $failureMessages)); } }//end testSniff()
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer.php?r1=1.24&r2=1.25&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer.php diff -u pear/PHP_CodeSniffer/CodeSniffer.php:1.24 pear/PHP_CodeSniffer/CodeSniffer.php:1.25 --- pear/PHP_CodeSniffer/CodeSniffer.php:1.24 Sat Apr 21 01:51:00 2007 +++ pear/PHP_CodeSniffer/CodeSniffer.php Sun Apr 22 04:32:33 2007 @@ -11,7 +11,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: CodeSniffer.php,v 1.24 2007/04/21 01:51:00 squiz Exp $ + * @version CVS: $Id: CodeSniffer.php,v 1.25 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -173,7 +173,7 @@ $this->_registerTokenListeners($standard, $sniffs); if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo "DONE\n"; + echo 'DONE'.PHP_EOL; } foreach ($files as $file) { @@ -374,7 +374,7 @@ $startTime = time(); echo 'Processing '.basename($file).' '; if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\n"; + echo PHP_EOL; } } @@ -385,11 +385,11 @@ if (PHP_CODESNIFFER_VERBOSITY > 0) { $timeTaken = (time() - $startTime); if ($timeTaken === 0) { - echo "DONE in < 1 second\n"; + echo 'DONE in < 1 second'.PHP_EOL; } else if ($timeTaken === 1) { - echo "DONE in 1 second\n"; + echo 'DONE in 1 second'.PHP_EOL; } else { - echo "DONE in $timeTaken seconds\n"; + echo "DONE in $timeTaken seconds".PHP_EOL; } } @@ -457,15 +457,15 @@ ksort($errors); - echo "\nFILE: "; + echo PHP_EOL.'FILE: '; if (strlen($filename) <= 71) { echo $filename; } else { echo '...'.substr($filename, (strlen($filename) - 71)); } - echo "\n"; - echo str_repeat('-', 80)."\n"; + echo PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; $numLines = count($errors); echo "FOUND $numErrors ERROR(S) "; @@ -473,8 +473,8 @@ echo "AND $numWarnings WARNING(S) "; } - echo "AFFECTING $numLines LINE(S)\n"; - echo str_repeat('-', 80)."\n"; + echo "AFFECTING $numLines LINE(S)".PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; // Work out the max line number for formatting. $maxLine = 0; @@ -507,7 +507,7 @@ foreach ($lineErrors as $error) { // The padding that goes on the front of the line. $padding = ($maxLineLength - strlen($line)); - $errorMsg = wordwrap($error['message'], $maxErrorSpace, "\n$paddingLine2"); + $errorMsg = wordwrap($error['message'], $maxErrorSpace, PHP_EOL."$paddingLine2"); echo ' '.str_repeat(' ', $padding).$line.' | '.$error['type']; if ($error['type'] === 'ERROR') { @@ -516,11 +516,11 @@ } } - echo ' | '.$errorMsg."\n"; + echo ' | '.$errorMsg.PHP_EOL; } }//end foreach - echo str_repeat('-', 80)."\n\n"; + echo str_repeat('-', 80).PHP_EOL.PHP_EOL; }//end foreach @@ -562,15 +562,15 @@ return; } - echo "\nPHP CODE SNIFFER REPORT SUMMARY\n"; - echo str_repeat('-', 80)."\n"; + echo PHP_EOL.'PHP CODE SNIFFER REPORT SUMMARY'.PHP_EOL; + echo str_repeat('-', 80).PHP_EOL; if ($showWarnings === true) { - echo 'FILE'.str_repeat(' ', 60)."ERRORS WARNINGS\n"; + echo 'FILE'.str_repeat(' ', 60).'ERRORS WARNINGS'.PHP_EOL; } else { - echo 'FILE'.str_repeat(' ', 70)."ERRORS\n"; + echo 'FILE'.str_repeat(' ', 70).'ERRORS'.PHP_EOL; } - echo str_repeat('-', 80)."\n"; + echo str_repeat('-', 80).PHP_EOL; $totalErrors = 0; $totalWarnings = 0; @@ -595,21 +595,21 @@ echo $errors['warnings']; } - echo "\n"; + echo PHP_EOL; $totalErrors += $errors['errors']; $totalWarnings += $errors['warnings']; $totalFiles++; }//end foreach - echo str_repeat('-', 80)."\n"; + echo str_repeat('-', 80).PHP_EOL; echo "A TOTAL OF $totalErrors ERROR(S) "; if ($showWarnings === true) { echo "AND $totalWarnings WARNING(S) "; } - echo "WERE FOUND IN $totalFiles FILE(S)\n"; - echo str_repeat('-', 80)."\n\n"; + echo "WERE FOUND IN $totalFiles FILE(S)".PHP_EOL; + echo str_repeat('-', 80).PHP_EOL.PHP_EOL; }//end printErrorReportSummary() http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.55&r2=1.56&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.55 pear/PHP_CodeSniffer/package.xml:1.56 --- pear/PHP_CodeSniffer/package.xml:1.55 Sat Apr 21 01:51:00 2007 +++ pear/PHP_CodeSniffer/package.xml Sun Apr 22 04:32:33 2007 @@ -35,6 +35,8 @@ - Fixed variable name error causing incorrect error message in Squiz ValidVariableNameSniff - Fixed bugs #10751, #10777 : Sniffer class paths handled incorrectly in Windows - Thanks to Carsten Wiedmann for the patch. + - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) + - Thanks to Carsten Wiedmann for the patch. </notes> <contents> <dir name="/"> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/File.php?r1=1.22&r2=1.23&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/File.php diff -u pear/PHP_CodeSniffer/CodeSniffer/File.php:1.22 pear/PHP_CodeSniffer/CodeSniffer/File.php:1.23 --- pear/PHP_CodeSniffer/CodeSniffer/File.php:1.22 Thu Mar 8 06:09:56 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/File.php Sun Apr 22 04:32:33 2007 @@ -11,7 +11,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: File.php,v 1.22 2007/03/08 06:09:56 squiz Exp $ + * @version CVS: $Id: File.php,v 1.23 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -411,7 +411,7 @@ public function start() { if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** START TOKEN PROCESSING ***\n"; + echo "\t*** START TOKEN PROCESSING ***".PHP_EOL; } // Foreach of the listeners that have registed to listen for this @@ -420,7 +420,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 2) { $type = $token['type']; $content = str_replace("\n", '\n', $token['content']); - echo "\t\tProcess token $stackPtr: $type => $content\n"; + echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL; } $tokenType = $token['code']; @@ -435,14 +435,14 @@ if (PHP_CODESNIFFER_VERBOSITY > 2) { $timeTaken = round((microtime(true) - $startTime), 4); - echo "DONE in $timeTaken seconds\n"; + echo "DONE in $timeTaken seconds".PHP_EOL; } } } }//end foreach if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** END TOKEN PROCESSING ***\n"; + echo "\t*** END TOKEN PROCESSING ***".PHP_EOL; } // We don't need the tokens any more, so get rid of them @@ -580,6 +580,9 @@ $numTokens = count($this->_tokens); $numLines = $this->_tokens[($numTokens - 1)]['line']; echo "[$numTokens tokens in $numLines lines]... "; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo PHP_EOL; + } } }//end _parse() @@ -828,7 +831,7 @@ private function _createScopeMap() { if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START SCOPE MAP ***\n"; + echo "\t*** START SCOPE MAP ***".PHP_EOL; } $numTokens = count($this->_tokens); @@ -838,7 +841,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$i]['type']; $content = str_replace("\n", '\n', $this->_tokens[$i]['content']); - echo "\tStart scope map at $i: $type => $content\n"; + echo "\tStart scope map at $i: $type => $content".PHP_EOL; } $i = $this->_recurseScopeMap($i); @@ -846,7 +849,7 @@ } if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END SCOPE MAP ***\n"; + echo "\t*** END SCOPE MAP ***".PHP_EOL; } }//end _createScopeMap() @@ -893,14 +896,14 @@ echo 'ignore;'; } - echo "]: $type => $content\n"; + echo "]: $type => $content".PHP_EOL; } // Is this an opening condition ? if (isset(self::$_scopeOpeners[$tokenType]) === true) { if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* token is an opening condition *\n"; + echo '* token is an opening condition *'.PHP_EOL; } $isShared = (self::$_scopeOpeners[$tokenType]['shared'] === true); @@ -909,7 +912,7 @@ // We've been here before. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* already processed, skipping *\n"; + echo '* already processed, skipping *'.PHP_EOL; } if ($isShared === false && isset($this->_tokens[$i]['scope_closer']) === true) { @@ -923,14 +926,14 @@ // share openers, so we will never find one. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* it was another token's opener, bailing *\n"; + echo '* it was another token\'s opener, bailing *'.PHP_EOL; } return $stackPtr; } else { if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* searching for closer *\n"; + echo '* searching for closer *'.PHP_EOL; } $i = $this->_recurseScopeMap($i, ($depth + 1)); @@ -942,7 +945,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found scope opener for $stackPtr ($type)\n"; + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; } $opener = $i; @@ -952,7 +955,7 @@ // offset or alike, so let's ignore it. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* finished ignoring curly brace *\n"; + echo '* finished ignoring curly brace *'.PHP_EOL; } $ignore = false; @@ -960,7 +963,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found scope closer for $stackPtr ($type)\n"; + echo "=> Found scope closer for $stackPtr ($type)".PHP_EOL; } foreach (array($stackPtr, $opener, $i) as $token) { @@ -998,7 +1001,7 @@ // map. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* ignoring curly brace *\n"; + echo '* ignoring curly brace *'.PHP_EOL; } $ignore = true; @@ -1009,7 +1012,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Couldn't find scope opener for $stackPtr ($type), bailing\n"; + echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; } return $stackPtr; @@ -1020,7 +1023,7 @@ // We found the end token for the opener we were ignoring. if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", $depth); - echo "* finished ignoring curly brace *\n"; + echo '* finished ignoring curly brace *'.PHP_EOL; } $ignore = false; @@ -1032,7 +1035,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", $depth); - echo "=> Found (unexpected) scope closer for $stackPtr ($type)\n"; + echo "=> Found (unexpected) scope closer for $stackPtr ($type)".PHP_EOL; } foreach (array($stackPtr, $opener) as $token) { @@ -1065,7 +1068,7 @@ private function _createLevelMap() { if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START LEVEL MAP ***\n"; + echo "\t*** START LEVEL MAP ***".PHP_EOL; } $numTokens = count($this->_tokens); @@ -1091,7 +1094,7 @@ echo rtrim($condString, ',').';'; } - echo "]: $type => $content\n"; + echo "]: $type => $content".PHP_EOL; } $this->_tokens[$i]['level'] = $level; @@ -1105,7 +1108,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", ($level + 1)); - echo "=> Found scope opener for $stackPtr ($type)\n"; + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; } $stackPtr = $this->_tokens[$i]['scope_condition']; @@ -1128,7 +1131,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$badToken]['type']; echo str_repeat("\t", ($level + 1)); - echo "* shared closer, cleaning up $badToken ($type) *\n"; + echo "* shared closer, cleaning up $badToken ($type) *".PHP_EOL; } for ($x = $this->_tokens[$i]['scope_condition']; $x <= $i; $x++) { @@ -1154,11 +1157,11 @@ $newLevel = $this->_tokens[$x]['level']; echo str_repeat("\t", ($level + 1)); - echo "* cleaned $x ($type) *\n"; + echo "* cleaned $x ($type) *".PHP_EOL; echo str_repeat("\t", ($level + 2)); - echo "=> level changed from $oldLevel to $newLevel\n"; + echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; echo str_repeat("\t", ($level + 2)); - echo "=> conditions changed from $oldConds to $newConds\n"; + echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; }//end if }//end for @@ -1166,7 +1169,7 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$badToken]['type']; echo str_repeat("\t", ($level + 1)); - echo "* token $badToken ($type) removed from conditions array *\n"; + echo "* token $badToken ($type) removed from conditions array *".PHP_EOL; } unset ($openers[$lastOpener]); @@ -1174,7 +1177,7 @@ $level--; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 2)); - echo "* level decreased *\n"; + echo '* level decreased *'.PHP_EOL; } }//end if }//end if @@ -1182,14 +1185,14 @@ $level++; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 1)); - echo "* level increased *\n"; + echo '* level increased *'.PHP_EOL; } $conditions[$stackPtr] = $this->_tokens[$stackPtr]['code']; if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$stackPtr]['type']; echo str_repeat("\t", ($level + 1)); - echo "* token $stackPtr ($type) added to conditions array *\n"; + echo "* token $stackPtr ($type) added to conditions array *".PHP_EOL; } $lastOpener = $this->_tokens[$i]['scope_opener']; @@ -1212,20 +1215,20 @@ if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->_tokens[$oldOpener]['type']; echo str_repeat("\t", ($level + 1)); - echo "=> Found scope closer for $oldOpener ($type)\n"; + echo "=> Found scope closer for $oldOpener ($type)".PHP_EOL; } if ($removedCondition === false) { $oldCondition = array_pop($conditions); if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 1)); - echo '* token '.token_name($oldCondition)." removed from conditions array *\n"; + echo '* token '.token_name($oldCondition)." removed from conditions array *".PHP_EOL; } $level--; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", ($level + 2)); - echo "* level decreased *\n"; + echo '* level decreased *'.PHP_EOL; } } @@ -1238,7 +1241,7 @@ }//end for if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END LEVEL MAP ***\n"; + echo "\t*** END LEVEL MAP ***".PHP_EOL; } }//end _createLevelMap() http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?r1=1.4&r2=1.5&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php diff -u pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.5 --- pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 Fri Dec 29 00:05:45 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php Sun Apr 22 04:32:33 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: AbstractSniffUnitTest.php,v 1.4 2006/12/29 00:05:45 squiz Exp $ + * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.5 2007/04/22 04:32:33 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -198,7 +198,7 @@ $foundMessage .= "$numErrors error(s)"; if ($numErrors !== 0) { $foundString .= 'error(s)'; - $errors .= implode("\n -> ", $problems['found_errors']); + $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); } if ($expectedWarnings !== $numWarnings) { @@ -217,13 +217,13 @@ $foundMessage .= "$numWarnings warning(s)"; if ($numWarnings !== 0) { $foundString .= 'warning(s)'; - $errors .= implode("\n -> ", $problems['found_warnings']); + $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); } } $fullMessage = "$lineMessage $expectedMessage $foundMessage."; if ($errors !== '') { - $fullMessage .= " The $foundString found were:\n -> $errors"; + $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; } $failureMessages[] = $fullMessage; @@ -231,7 +231,7 @@ }//end foreach if (empty($failureMessages) === false) { - $this->fail(implode("\n", $failureMessages)); + $this->fail(implode(PHP_EOL, $failureMessages)); } }//end testSniff()