1.2.1283. Unused Class Constant

The class constant is unused. Consider removing it or using it.

Class constants may be used in expressions, in static expressions, when building other constants, or in default values.

<?php

class foo {
    public const UNUSED = 1; // No mention in the code

    private const USED = 2;  // used constant

    function bar() {
        echo self::USED;
    }
}

?>

1.2.1283.1. Suggestions

  • Remove the class constant

  • Use the class constant

1.2.1283.2. Specs

Short name

Classes/UnusedConstant

Rulesets

All, Analyze, Changed Behavior, Class Review

Exakat since

1.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

class-constant

Available in

Entreprise Edition, Exakat Cloud