PHP S1185: False positive with method attributes

Make sure to read this post before raising a thread here:

Inspection S1185 for PHP (Overriding methods should do more than simply call the same method in super class) generates false positive when the child only adds an attribute.

Example:

abstract class BaseFoo {
  public function getFoo(): string { return 'foo'; }
}
class Foo {
  #[\Deprecated]
  public function getFoo(): string { return parent::getFoo(); }
}

(I previously searched for similar topics with S1185 and S1185 attribute)

Attributes can be used for a wild variety of things (validation, dependency injection changes etc…) and you may not be able to use them on the parent class (generated files, external dependencies etc…).

I observe this false positive on:

  • SonarQube Server: Enterprise Edition - v2025.1.1 (104738)
  • SonarQube for IDE: 12.2.2.84629 (PHPStorm)

Hi,

Welcome to the community and thanks for this report!

Your SonarQube Server is stale, but your SonarQube for IntelliJ version is current. Can you reproduce this in SQ4IDE in standalone / not-connected mode?

 
Thx,
Ann

Your SonarQube Server is stale, but your SonarQube for IntelliJ version is current. Can you reproduce this in SQ4IDE in standalone / not-connected mode?

Yes I have the same issue on SQ4IDE that is not binded to a server. I could have specified this on the original post.

Hi,

Thanks for the confirmation, and no worries! :slight_smile:

I’ve flagged this for the language experts.

 
Ann