1.2.266. Could Be Protected Property

Those properties are declared public, but are never used publicly. They may be made protected.

This property may even be made private.

<?php

class foo {
    // Public, and used publicly
    public $publicProperty;
    // Public, but never used outside the class or its children
    public $protectedProperty;

    function bar() {
        $this->protectedProperty = 1;
    }
}

$foo = new Foo();
$foo->publicProperty = 3;

?>

1.2.266.1. Connex PHP features

1.2.266.1.1. Suggestions

  • Use protected visibility with these properties.

1.2.266.1.2. Specs

Short name

Classes/CouldBeProtectedProperty

Rulesets

All, Changed Behavior, Class Review

Exakat since

0.9.7

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

High

Available in

Entreprise Edition, Exakat Cloud