php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81126 Destructor is invoked even if invoked manually already
Submitted: 2021-06-10 19:51 UTC Modified: 2021-06-10 20:50 UTC
From: m at m dot cz Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 8.0.7 OS: any
Private report: No CVE-ID: None
 [2021-06-10 19:51 UTC] m at m dot cz
Description:
------------
see https://3v4l.org/AjLjK

Test script:
---------------
<?php

$a = new class {
    public function __destruct() {
        echo '__destruct called' . "\n";
    }
};

$a->__destruct();
$a = null;

Expected result:
----------------
__destruct called

and maybe some warning as __destruct should not be called manually

Actual result:
--------------
__destruct called
__destruct called

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-10 20:50 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2021-06-10 20:50 UTC] nikic@php.net
The behavior is correct.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC