1.2.652. Magic Visibility

Magic methods must be declared with public visibility. They cannot be private or protected.

Magic methods cannot be declared as static. They are always associated with an instance of a class and cannot be called statically.

<?php

class foo{
    // magic method must bt public and non-static
    public static function __clone($name) {    }

    // magic method can't be private
    private function __get($name) {    }

    // magic method can't be protected
    private function __set($name, $value) {    }

    // magic method can't be static
    public static function __isset($name) {    }
}

?>

See also Magic methods and PHP Magic Methods Explained.

1.2.652.1. Specs

Short name

Classes/toStringPss

Rulesets

All, Changed Behavior, CompatibilityPHP70

Exakat since

0.8.4

PHP Version

With PHP 5.4 and older

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Features

visibility, magic-method

Available in

Entreprise Edition, Exakat Cloud