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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 12 = ?
Subscribe to this entry?

 
 [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: Wed May 01 21:01:29 2024 UTC