SyntaxStudy
Sign Up
PHP Intermediate 5 min read

Extending Interfaces

Interface Inheritance

Interfaces can extend other interfaces with extends. The child interface inherits all methods from the parent and can add more.

Example
<?php
interface Readable {
    public function read(): string;
}

interface Writable {
    public function write(string $data): void;
}

// ReadWrite extends both
interface ReadWrite extends Readable, Writable {
    public function seek(int $position): void;
}

class FileStream implements ReadWrite {
    public function read(): string { return "data"; }
    public function write(string $data): void {}
    public function seek(int $position): void {}
}
Pro Tip

Interface inheritance lets you build layered contracts — start with narrow interfaces and compose them into broader ones.