diff --git a/Tests/VariableAnalysisSniff/GlobalScopeTest.php b/Tests/VariableAnalysisSniff/GlobalScopeTest.php index a7ddb7e..2ec7506 100644 --- a/Tests/VariableAnalysisSniff/GlobalScopeTest.php +++ b/Tests/VariableAnalysisSniff/GlobalScopeTest.php @@ -18,10 +18,11 @@ public function testGlobalScopeWarnings() $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedErrors = [ - 4, - 7, - 10, - 13, + 3, + 5, + 8, + 11, + 14, ]; $this->assertSame($expectedErrors, $lines); } @@ -38,9 +39,10 @@ public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope() $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedErrors = [ - 4, - 10, - 13, + 3, + 5, + 11, + 14, ]; $this->assertSame($expectedErrors, $lines); } @@ -57,8 +59,9 @@ public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedErrors = [ - 7, - 10, + 3, + 8, + 11, ]; $this->assertSame($expectedErrors, $lines); } diff --git a/Tests/VariableAnalysisSniff/fixtures/GlobalScopeFixture.php b/Tests/VariableAnalysisSniff/fixtures/GlobalScopeFixture.php index 4d5688f..e6b3bc8 100644 --- a/Tests/VariableAnalysisSniff/fixtures/GlobalScopeFixture.php +++ b/Tests/VariableAnalysisSniff/fixtures/GlobalScopeFixture.php @@ -1,5 +1,6 @@ findPrevious([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $stackPtr - 1, null, false, null, true); $staticPtr = $phpcsFile->findPrevious([T_STATIC], $stackPtr - 1, null, false, null, true); if (! is_int($startOfStatement)) { - $line = $tokens[$stackPtr]['line']; - throw new \Exception("Could not find start of statement on line {$line}"); + $startOfStatement = 1; } if (! is_int($staticPtr)) { return false;