Doc #71480 [Opn->Nab]: __destruct documentation incorrect

From: Date: Thu, 28 Jan 2016 21:56:18 +0000
Subject: Doc #71480 [Opn->Nab]: __destruct documentation incorrect
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13146@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71480&edit=1 ID: 71480 Updated by: requinix@php.net Reported by: bowersbros at gmail dot com Summary: __destruct documentation incorrect -Status: Open +Status: Not a bug Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: In that code the destructor is called immediately because the object isn't being persisted anywhere and so it gets cleaned up on the spot. The docs are talking about something more like https://3v4l.org/QL4ie Previous Comments: ------------------------------------------------------------------------ [2016-01-28 20:48:05] bowersbros at gmail dot com Description: ------------ --- From manual page: http://www.php.net/language.oop5.decon --- > Attempting to throw an exception from a destructor (called in the time of script termination) > causes a fatal error. From the '__destruct()' section. With this simple test script, I was not able to get it to throw an actual Fatal Error, but the Exception itself was thrown Test script: --------------- <?php class Testing { public function test() { return $this; } public function __destruct() { throw new \InvalidArgumentException(); } } try { (new Testing())->test(); } catch (Exception $e) { echo 'Caught the exception'; } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71480&edit=1

« previous php.doc.bugs (#13146) next »