php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43264 __destruct
Submitted: 2007-11-12 14:26 UTC Modified: 2007-11-12 17:38 UTC
From: miha dot vrhovnik at domenca dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
 [2007-11-12 14:26 UTC] miha dot vrhovnik at domenca dot com
Description:
------------
PHP 5.2.4 doesn't provide default class destructor and exits with 
Fatal error: Call to undefined method base::__destruct() in /path/to/bug.php on line 23

For me coming from Delphi waters this is a bug.
If php would provide default class destructor you could write future proof code
I think that there is no need to explain what I mean with that especially after reading this in documentation:
> Like constructors, parent destructors will not be called implicitly 
> by the engine. In order to run a parent destructor, one would have 
> to explicitly call parent::__destruct() in the destructor body.

Reproduce code:
---------------
error_reporting(E_ALL);

$c = new extender();

class base
{
    public function __constructor()
    {
        parent::__construct();
    }
    
}

class extender extends base
{
    public function __constructor()
    {
        parent::__construct();
    }
    
    
    public function __destruct()
    {
        parent::__destruct();
    }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-12 17:38 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PHP is a unique language and there isn\'t even a parent class to your base class, so there\'s no class which could offer such a feature. Adding some magic won\'t fit to the engine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC