Why do you believe it’s a false-positive/false-negative?
In case (see below), the object is created inside a try/catch block,
In case of a validation function for example, It may be used to check the validity of some variable passed to a constructor.
SonarQube - in Developer Edition
SonarLint - which IDE/version connected mode with SonarQube
Example Code to reproduce:
function isValidDate() {
try {
new DateTime($varToTest);
} catch (Exception $exception) {
return false;
}
return true;
}
Welcome to the community. Thank you for your report.
Your case has led to some internal discussion about whether this is a clean way to check the format of an input value. We have come to the conclusion that we want to allow this. For this reason, I have created the following ticket, which we will implement in one of the next iterations.