#672·prophecy

PHP 8.6 - Returning a value from a destructor is deprecated

Author: mondrakeCreated Jul 4, 2026Updated Jul 5, 2026

When a doubled class specifies a __destruct method, ClassCodeGenerator currently builds

<?php
namespace Double\\\xxxx {
class P1 extends \\\xxxx implements \Prophecy\Doubler\DoubleInterface, \Prophecy\Prophecy\ProphecySubjectInterface, \Prophecy\Doubler\Generator\ReflectionInterface {

...

public  function __destruct() {
return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());
}

...

}

and this will throw a deprecation in PHP 8.6.

It's due to PHP RFC: Deprecate returning values from __construct() and __destruct(), that was committed in https://github.com/php/php-src/pull/21982.