1.2.1026. Redefined Private Property

Private properties are local to their defined class. PHP doesn’t forbid the re-declaration of a private property in a child class.

However, having two or more properties with the same name, in the class hierarchy tends to be error prone. Methods will be accessing properties with the same name, but with different values.

<?php

class A {
    private $isReady = true;
}

class B {
    private $isReady = false;
}

?>

1.2.1026.1. Suggestions

  • Remove the property in the children classes

  • Rename the property in the children classes

  • Change the visibility in the parent class

1.2.1026.2. Specs

Short name

Classes/RedefinedPrivateProperty

Rulesets

All, IsExt, IsPHP, IsStub

Exakat since

1.2.3

PHP Version

All

Severity

Major

Time To Fix

Slow (1 hour)

Precision

Very high

Features

private

Examples

Zurmo

Available in

Entreprise Edition, Exakat Cloud