Destructors cannot declare a return type

Description

There can be no return type for a destructor method. It is called while destroying an existing instance of an object, and the object won’t be available at the end.

Example

<?php

class x {
     function __destruct() : int {

     }
}

?>

Solutions

  • Remove the return type of the method.