PHP S100 not scanning when class extended

Hello,
I’m using sonarqube 9.9.3 also tested with 10.7
Using self hosted sonarqube
I have php file with class with extended, Below is example of it.
Here I’m not getting php:s100 error for function name.
It works if class is not extended.

class test extends someModel
{
	public function some_method()
	{
		return true;
	}
}

Hi,

Welcome to the community and thanks for this report!

I believe this isn’t about the extended class, but about the fact that it’s a test. Most rules, and particularly naming rules, don’t run on tests.

You say the rule works if the class isn’t extended. Were your examples of this with test classes?

 
HTH,
Ann

Attached screenshot for more information.


With Extended Class:

Hi,

Thanks for the non-test examples. I’ll flag this for the language experts.

 
Ann

Hello @Himanshu_Koshti and welcome to the community!

This rule has a failsafe mechanism: if the analyzer cannot resolve the parent class, it cannot be sure if the method is overridden or not. To avoid a FP in case it is overridden, the analyzer doesn’t check its naming.

In your case, AFAIU, the Authenticatable parent class comes from Laravel. Unfortunately, the analyzer cannot resolve a class from a dependency, unless the sources are also present in the project.

To sum up, this behavior is expected considering the limitations of the analyzer.

Hi Peter,

Thanks for explanations, Is there any workaround on this?

Hi @Himanshu_Koshti,

Unfortunately, there is no workaround. I created a ticket and you can monitor progress on it, but since it would be a major feature, we don’t plan to implement it in the nearest sprints.

Hope that helps,

Peter