<?php


class X
{
    public function __destruct(){
        throw new \Exception('eee');
    }
}


class InstanceTest extends \PHPUnit\Framework\TestCase
{

    // This part is important, and is what's causing the crash:
    private ?X $x = null;
    function get_instance():X{return $this->x = $this->get_new_instance();}
    function get_new_instance():X{return new X();}


    public function test_instance()
    {
        $this->get_instance();
        $this->assertTrue(true);
    }
}