Anonymous class method %s() must not be abstract

Description

An anonymous class cannot have an abstract method, as the class is actually immediately instantiate, while abstract class, and classes that contains an abstract method cannot be instantiated.

This error was also detected previously, with a more generic error message.

Example

<?php

new class() {
    abstract function foo();
}

?>

Literal Examples

  • Anonymous class method foo() must not be abstract

Solutions

  • Remove the abstract method.

  • Add a body to the abstract method, and remove the abstract option.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.