[PHP] SonarAnalyzer rules : Static members should be referenced with "static::"

42 views
Skip to first unread message

jason.br...@gmail.com

unread,
Jul 20, 2016, 5:33:08 AM7/20/16
to SonarQube
Hi,


I think the rule 'Static members should be referenced with "static::"' should have another exception:

Consider this code:
class SomeClass
   
private static $somevar = null;

   
private static function getVars()
   
{
       
if (self::$
somevar == null) {
           
self::$
somevar = array();
       
}
   
}
}

The sonar rule report error on self::$somevar lines, but as these are used in a private function, i find no reason to prefer static::$somevar over self::$somevar...
What do you think?



Elena Vilchik

unread,
Oct 10, 2016, 4:48:38 AM10/10/16
to SonarQube, jason.br...@gmail.com
Hello,

Ticket is created to improve the rule SONARPHP-644

Thanks for the feedback!

Elena VILCHIK | SonarSource
Language Team
Reply all
Reply to author
Forward
0 new messages