1.2.1050. Rewrote Final Class Constant

Final class constants can’t be rewriten in a child class.

It is possible to write code that lints, when the classes are in different files. Such overwrites will only be detected at execution time.

<?php

class x {
     final const A = 1;
     const B = 1;
}

class y extends x {
     const A = 1;
     const B = 1;
}

?>

1.2.1050.1. Suggestions

  • Remove the final keyword

  • Remove the rewritten constant

1.2.1050.2. Specs

Short name

Classes/RewroteFinalClassConstant

Rulesets

All, Class Review

Exakat since

2.5.4

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

final

Available in

Entreprise Edition, Exakat Cloud