PHP S1144 – False positive with first-class callables still occurring

Hi SonarSource team,

We’ve recently encountered what appears to be a recurring false positive with PHP rule S1144 (“Unused private methods should be removed”) when using first-class callables.

This issue was originally reported back in August 2023 and was confirmed as a false positive by you:

As far as we understand, this issue was fixed in August 2023 with PR #1110.

However, we’re still encountering a case where private methods referenced through first-class callable syntax are incorrectly flagged as unused.

It seems that the detection does not work consistently across all scenarios, or the issue may have been reintroduced.

Example

We’ve encountered the following case in our codebase:

Example – False positive

[screenshots: Code example showing a private method incorrectly flagged by S1144]

The affected method is referenced and used through first-class callables, so they should not be considered unused.

Expected behavior

Private methods referenced via PHP’s first-class callable syntax should be recognized as used and should not trigger rule S1144.

Actual behavior

SonarQube reports these methods as unused, even though they are referenced through first-class callables.

Question

Could you please take another look at this issue?

Is this a known regression, or are there still specific scenarios involving first-class callables that are not fully covered by the original fix?

We’d appreciate any feedback on whether this is already being tracked or if a new ticket should be created.

Thanks in advance for your help!

Hi Mark,

Thanks for reporting the issue. It is indeed a false positive and should not be reported by SonarQube. We’ve fixed the issue and the FP shouldn’t be raised in the next release.

thanks @stefan.schott for your feedback