Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Interface %s cannot extend class %s

Description

An interface must extends another interface. It cannot extends a class, nor a trait, nor an enum.

Also, a class cannot extends an interface: it must implement it.

Example

<?php

class X {}

interface I extends X {} 

?>

Literal Examples

  • Interface I cannot extend class C

Alternatives

  • Turn the original class into an interface.
  • Make the original interface into an class.
  • Split the class into a class and an interface, and extends the latter.