1.2.588. Interfaces Usage

List of used interfaces.

Interfaces are used when mentioned in a class or another interface, with implements keyword; they are used in instanceof expression, in typehints and class constant.

<?php

// interface definition
interface i {
    const I = 2;
}

// interface extension
interface i2 extends i {}

// interface implementation
class foo implements i {}

$foo = new foo();

var_dump($foo instanceof i);

function bar( i $arg) { }
bar($foo);

// in class constant
echo i::I;

?>

1.2.588.1. Specs

Short name

Interfaces/InterfaceUsage

Rulesets

All, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

interface

Available in

Entreprise Edition, Exakat Cloud