final
keyword is redundant PHP-W1082The final
keyword prevents child classes from overriding methods or constants with the final
prefix.
Here, the class is already defined as final
; therefore, prefixing the class methods or the constants with final
is redundant and safely be dropped.
final class User
{
// invalid: `final` keyword is redundant here
final public function getDetails()
{
// implementation for the method
}
}
final class Status
{
// invalid: `final` keyword is redundant here
final public const ACTIVE = 1;
}
final class User
{
public function getDetails()
{
// implementation for the method
}
}
final class Status
{
public const ACTIVE = 1;
}