Incorrect Code smell php:S1125

In php, boolean operators like && and || always return a boolean!

Code where the incorrect rule triggers:

return $condition ? true : $exp;

That code is not equivalent to

return $condition || $exp;

This happens in Sonarlint v4.0.2.3009 Intellij Idea plugin.

For you to play around and test:

PS: This is related to Incorrect warning squid:S1125

Indeed, we should reduce the scope of that rule for PHP.
Ticket created: SONARPHP-906

Thanks a lot for your feedback!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.