1.2.1156. Strange Names In Classes

Those methods, properties, constants or types should have another name.

Ever wondered why the __constructor is never called? Or the __consturct ?

Those errors most often originate from typos, or quick fixes that where not fully tested. Other times, they were badly chosen, or ran into PHP’s own reserved keywords.

<?php

class foo {
    // The real constructor
    function __construct() {}

    // The fake constructor
    function __constructor() {}

    // The 'typo'ed' constructor
    function __consturct() {}

    // This doesn't clone
    function clone() {}
}

?>

1.2.1156.1. Suggestions

  • Use the proper name

  • Remove the method, when it is not used and tests still pass.

1.2.1156.2. Specs

Short name

Classes/StrangeName

Rulesets

All, Semantics

Exakat since

0.10.1

PHP Version

All

Severity

Major

Time To Fix

Slow (1 hour)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud