1.2.706. Missing Visibility

Class constants, properties and methods usage may be controlled by the visibility option. When omitted, it is by default public.

When omitted, it should be added to make its configuration explicit.

<?php

class x {
    // property is private
    private $property = 1;

    // This method is public, and should bear the 'public' option
    function foo() {}
}

?>

See also Visibility.

1.2.706.1. Suggestions

  • Add the public visibility

  • Actually review the code and set a pragmatic visibility

  • Set the visibility to private and wait for a request of access

1.2.706.2. Specs

Short name

Classes/MissingVisibility

Rulesets

All, Changed Behavior, Class Review

Exakat since

2.3.5

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

visibility

Related rule

Ambiguous Visibilities

Available in

Entreprise Edition, Exakat Cloud