Is there a way to avoid the parent::
static accessor in PHP classes, or is this one of those times to use @SuppressWarnings(StaticAccess)
?
On the same lines, it seems like this StaticAccess
warning is popping in suspicious places. Exception handling, for instance - when I throw new Exception(...)
, PHPMD complains about static access. But...there's not really another way to do it (that I've found) so I've got more warnings suppressors than I'd like. Is this normal?
EDIT
As requested, here's an 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 will report two errors with the above: a StaticAccess
error on the Exception
, and a StaticAccess
error on the parent::__construct()
call.
To avoid that, I've got to notate both classes with @SuppressWarnings
, which seems clunky, and also won't show "real" static access problems.