Naming Long Class Name
ID |
php.naming_long_class_name |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming Convention |
Language |
Php |
Tags |
naming |
Description
Reports class, interface, trait and enum names whose length exceeds a configurable threshold (40 characters by default). Anonymous classes have no name and are never reported.
Rationale
A very long type name is usually a sign that the type is doing too much: the name keeps
growing to describe every responsibility the class accumulated. Long names also wrap on
narrow screens, clutter call sites and use statements, and make the code harder to scan.
Keeping names concise pushes the design toward types with a single, clear purpose.
<?php
class ThisIsAnExtremelyLongClassNameThatGoesWayTooFar {} // FLAW - exceeds 40 characters
class UserRepository {} // OK - concise and descriptive
interface PaymentGateway {} // OK
trait Loggable {} // OK