1.2.411. Empty Interfaces

Empty interfaces are a code smell. Interfaces should contains at least a method or a constant, and not be totally empty.

<?php

// an empty interface
interface empty {}

// an normal interface
interface normal {
    public function i() ;
}

// a constants interface
interface constantsOnly {
    const FOO = 1;
}

?>

See also Empty interfaces are bad practice and Blog : Are empty interfaces code smell?.

1.2.411.1. Suggestions

  • Remove the interface

  • Add some methods or constants to the interface

1.2.411.2. Specs

Short name

Interfaces/EmptyInterface

Rulesets

All, Analyze, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

High

Features

interface

Available in

Entreprise Edition, Exakat Cloud