[php7] Use destructor action if present

If there's a destructor, use its action instead of free(ptr)
(for C)/delete ptr (for C++).

Fixes #2108
This commit is contained in:
Olly Betts 2021-12-02 18:00:39 +13:00 committed by Olly Betts
commit c25df74807
2 changed files with 43 additions and 9 deletions

View file

@ -0,0 +1,17 @@
<?php
require "tests.php";
check::equal(fooCount(), 0, "no Foo objects expected");
$foo = makeFoo();
check::equal(get_class($foo), "Foo", "static failed");
check::equal(fooCount(), 1, "1 Foo object expected");
$bar = makeFoo();
check::equal(get_class($bar), "Foo", "regular failed");
check::equal(fooCount(), 2, "2 Foo objects expected");
$foo = null;
check::equal(fooCount(), 1, "1 Foo object expected");
$bar = null;
check::equal(fooCount(), 0, "no Foo objects expected");
check::done();