Incorrect Code smell php:S1125

php
sonarlint

(Michael Große) #1

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: https://3v4l.org/STjfO

PS: This is related to Incorrect warning squid:S1125


(Pierre-Yves Nicolas) #2

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

Thanks a lot for your feedback!