php - PHPMD avoid static access to parent -


is there way avoid parent:: static accessor in php classes, or 1 of times use @suppresswarnings(staticaccess)?

on same lines, seems staticaccess warning popping in suspicious places. exception handling, instance - when throw new exception(...), phpmd complains static access. but...there's not way (that i've found) i've got more warnings suppressors i'd like. normal?

edit

as requested, here's example - it's pretty straightforward:

class aaa {     private $somereasonforanexception = true;      public function __construct() {         echo 'aaa<br>';         if ($this->somereasonforanexception) {             throw new exception("something happened that's worth noticing!");         }     } }  class bbb extends aaa {         public function __construct() {         echo 'bbb<br>';         parent::__construct();     } }  $bbb = new bbb(); 

phpmd report 2 errors above: staticaccess error on exception, , staticaccess error on parent::__construct() call.

to avoid that, i've got notate both classes @suppresswarnings , seems clunky, , won't show "real" static access problems.

there no other way reference parent's method implementation on php. there nothing wrong code, phpmd drunk. problem you'd have static access because php allows call instance method static method if not reference $this variable, there no point on doing so. can ignore kind of warning.

edit:

if have this:

class foo {     public function bar() {         echo 'bar';     } } 

php allow do:

foo::bar(); // works 

but if have this:

class foo {     private $bar = 'bar';     public function bar() {         echo $this->bar;     } }  foo::bar(); // fatal error 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -