Skip to content

MIR0228

NotAnInterface

A type that is expected to be an interface is actually a class or another type. This commonly occurs when using interfaces for dependency injection or type hints where only interfaces should be used.

<?php
class Service {}
// Error: Service is a class, not an interface
interface Repository extends Service {
function find(int $id);
}

Ensure the type is actually an interface:

<?php
interface ServiceInterface {
function execute();
}
interface Repository extends ServiceInterface {
function find(int $id);
}