diff --git a/php-checks/src/main/java/org/sonar/php/checks/ReassignedBeforeUsedCheck.java b/php-checks/src/main/java/org/sonar/php/checks/ReassignedBeforeUsedCheck.java index 4e0b937265..da2aab2eec 100644 --- a/php-checks/src/main/java/org/sonar/php/checks/ReassignedBeforeUsedCheck.java +++ b/php-checks/src/main/java/org/sonar/php/checks/ReassignedBeforeUsedCheck.java @@ -26,6 +26,7 @@ import org.sonar.php.cfg.LiveVariablesAnalysis; import org.sonar.plugins.php.api.cfg.ControlFlowGraph; import org.sonar.plugins.php.api.symbols.Symbol; +import org.sonar.plugins.php.api.tree.CompilationUnitTree; import org.sonar.plugins.php.api.tree.Tree; import org.sonar.plugins.php.api.tree.declaration.FunctionDeclarationTree; import org.sonar.plugins.php.api.tree.declaration.FunctionTree; @@ -43,6 +44,12 @@ public class ReassignedBeforeUsedCheck extends PHPVisitorCheck { private final Set investigatedParameters = new HashSet<>(); + @Override + public void visitCompilationUnit(CompilationUnitTree tree) { + investigatedParameters.clear(); + super.visitCompilationUnit(tree); + } + @Override public void visitFunctionDeclaration(FunctionDeclarationTree tree) { visitFunctionTree(tree); diff --git a/php-checks/src/main/java/org/sonar/php/checks/phpunit/NoAssertionInTestCheck.java b/php-checks/src/main/java/org/sonar/php/checks/phpunit/NoAssertionInTestCheck.java index b18ac9137b..d51f0e8462 100644 --- a/php-checks/src/main/java/org/sonar/php/checks/phpunit/NoAssertionInTestCheck.java +++ b/php-checks/src/main/java/org/sonar/php/checks/phpunit/NoAssertionInTestCheck.java @@ -33,6 +33,7 @@ import org.sonar.php.tree.TreeUtils; import org.sonar.plugins.php.api.symbols.Symbol; import org.sonar.plugins.php.api.symbols.SymbolTable; +import org.sonar.plugins.php.api.tree.CompilationUnitTree; import org.sonar.plugins.php.api.tree.Tree; import org.sonar.plugins.php.api.tree.declaration.MethodDeclarationTree; import org.sonar.plugins.php.api.tree.expression.ExpressionTree; @@ -52,6 +53,12 @@ public class NoAssertionInTestCheck extends PhpUnitCheck { private final Map assertionInMethod = new HashMap<>(); + @Override + public void visitCompilationUnit(CompilationUnitTree tree) { + assertionInMethod.clear(); + super.visitCompilationUnit(tree); + } + @Override public void visitMethodDeclaration(MethodDeclarationTree tree) { if (!isTestCaseMethod(tree)) {