Bug #77882 [Asn->Csd]: Different behavior: always calls destructor

From: Date: Mon, 15 Apr 2019 08:24:12 +0000
Subject: Bug #77882 [Asn->Csd]: Different behavior: always calls destructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220452@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77882&edit=1 ID: 77882 Updated by: nikic@php.net Reported by: qRoC dot Work at gmail dot com Summary: Different behavior: always calls destructor -Status: Assigned +Status: Closed Type: Bug Package: Reflection related Operating System: All PHP Version: Irrelevant Assigned To: nikic Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9c0367fdc4653331f398df36a10db1c54d6f3df Log: Fixed bug #77882 Previous Comments: ------------------------------------------------------------------------ [2019-04-12 09:35:46] qRoC dot Work at gmail dot com Description: ------------ If we throw exception from constructor and create object by "new" - destructor never called. But if we create object by ReflectionClass - destructor always by called. Test script: --------------- <?php class Test { public function __construct() { throw new Exception(); } public function __destruct() { echo '__destruct'; } } try { new Test(); } catch(Exception $e) { } echo '--'; try { $ref = new ReflectionClass('Test'); $obj = $ref->newInstance(); } catch(Exception $e) { } Expected result: ---------------- -- Actual result: -------------- --__destruct ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77882&edit=1

« previous php.bugs (#220452) next »