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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: m at m dot cz
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 06:01:34 2025 UTC