Declared Before Or After

<?php

// defined before the parent class : no error
class y extends x {}

abstract class x {
    abstract function foo();
}

// defined after the parent class : error
class y2 extends x {}

?>

PHP takes the opportunity to validate everything it can when it is handy, and leave the rest to execution time. In the code below, the first class has no error reported, because it is linted before the parent class. The last class displays an error because it appears after the definition of the parent, and PHP can lazily check it.

The validation of the first class will be more thorough at execution time, and yield the error then.

See Also

PHP Error Messages

PHP Features

Last updated: 14 July 2026