Skip to content

Commit bfad537

Browse files
committed
Fix expected warning counts in unit tests to match bug fix in PHP_CodeSniffer test harness.
1 parent 4d53127 commit bfad537

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,6 @@ protected function processVariable(
11341134
if (($currScope = $this->findVariableScope($phpcsFile, $stackPtr)) === false) {
11351135
return;
11361136
}
1137-
11381137

11391138
//if ($varName == 'param') {
11401139
//echo "Found variable {$varName} on line {$token['line']} in scope {$currScope}.\n";// . print_r($token, true);

Tests/CodeAnalysis/VariableAnalysisUnitTest.php

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @package PHP_CodeSniffer
99
* @author Greg Sherwood <gsherwood@squiz.net>
1010
* @author Manuel Pichler <mapi@manuel-pichler.de>
11-
* @copyright 2007-2008 Manuel Pichler. All rights reserved.
11+
* @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
12+
* @copyright 2011 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
1213
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
13-
* @version CVS: $Id$
1414
* @link http://pear.php.net/package/PHP_CodeSniffer
1515
*/
1616

@@ -23,7 +23,8 @@
2323
* @category PHP
2424
* @package PHP_CodeSniffer
2525
* @author Manuel Pichler <mapi@manuel-pichler.de>
26-
* @copyright 2007-2008 Manuel Pichler. All rights reserved.
26+
* @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
27+
* @copyright 2011 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
2728
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
2829
* @version Release: @package_version@
2930
* @link http://pear.php.net/package/PHP_CodeSniffer
@@ -45,14 +46,6 @@ private function _getWarningAndErrorList() {
4546
//
4647
// This makes adding new tests only moderately painful rather than
4748
// a total clusterfuck of alterations.
48-
//
49-
// Comments with an unexplained number at the start before the name
50-
// of several variables are probably a reminder that there's multiple
51-
// errors on that line, but I had to pretend only one error because
52-
// AbstractSniffUnitTest doesn't reliably count all the errors. :(
53-
// This unfortunately means some of our test cases could fail and
54-
// we'd never notice.
55-
// TODO: track down that bug, fix and submit upstream.
5649
$base = 0;
5750
return array(
5851
// function_without_param() line (+3)
@@ -66,7 +59,7 @@ private function _getWarningAndErrorList() {
6659
($base + 7) => 1, // $var
6760
($base + 8) => 1, // $var
6861
($base + 9) => 1, // $var
69-
($base + 10) => 1, // $var
62+
($base + 10) => 1, // $var
7063
($base + 15) => 1, // $var2
7164
($base + 16) => 1, // $var2
7265
// function_with_param() line (+24)
@@ -88,16 +81,16 @@ private function _getWarningAndErrorList() {
8881
($base + 5) => 1, // $array
8982
($base + 9) => 1, // $array
9083
($base + 13) => 1, // $array
91-
($base + 17) => 1, // 2, // $array, $element3
92-
($base + 19) => 1, // 2, // $array, $element4
93-
($base + 21) => 1, // 3, // $array, $key3, $value4
94-
($base + 23) => 1, // 3, // $array, $key4, $value4
84+
($base + 17) => 2, // $array, $element3
85+
($base + 19) => 2, // $array, $element4
86+
($base + 21) => 3, // $array, $key3, $value4
87+
($base + 23) => 3, // $array, $key4, $value4
9588
// function_with_defined_foreach() line (+27)
9689
($base += 27) => 0,
9790
($base + 18) => 1, // $element3
9891
($base + 20) => 1, // $element4
99-
($base + 22) => 1, // 2, // $key3, $value4
100-
($base + 24) => 1, // 2, // $key4, $value4
92+
($base + 22) => 2, // $key3, $value4
93+
($base + 24) => 2, // $key4, $value4
10194
// ClassWithoutMembers->method_without_param() line (+29)
10295
($base += 29) => 0,
10396
($base + 1) => 1, // $var
@@ -153,12 +146,12 @@ private function _getWarningAndErrorList() {
153146
($base += 29) => 0,
154147
// function_with_static_var() line (+5)
155148
($base += 5) => 0,
156-
($base + 1) => 1, // 5, // $static_neg_num, $static_string, $static_string2,
149+
($base + 1) => 5, // $static_neg_num, $static_string, $static_string2,
157150
// $static_define, $static_constant
158-
($base + 13) => 1, // $var
151+
($base + 13) => 1, // $var
159152
// function_with_pass_by_reference_param() line (+20)
160153
// no warnings.
161-
($base += 20) => 0,
154+
($base += 20) => 0,
162155
// function_with_pass_by_reference_calls() line (+4)
163156
($base += 4) => 0,
164157
($base + 1) => 1, // $matches
@@ -182,7 +175,7 @@ private function _getWarningAndErrorList() {
182175
($base += 15) => 0,
183176
($base + 3) => array(0, 1), // $self::$static_member
184177
// function_with_inline_assigns() line (+9)
185-
($base += 9) => 0,
178+
($base += 9) => 0,
186179
($base + 1) => 1, // $var
187180
($base + 4) => 1, // $var2
188181
// function_with_global_redeclarations() line (+11)

0 commit comments

Comments
 (0)