Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101988 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11127 invoked from network); 20 Mar 2018 22:20:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2018 22:20:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=dennis@birkholz.biz; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@dennis.birkholz.biz; sender-id=pass Received-SPF: pass (pb1.pair.com: domain birkholz.biz designates 144.76.185.252 as permitted sender) X-PHP-List-Original-Sender: dennis@birkholz.biz X-Host-Fingerprint: 144.76.185.252 mail01.nexxes.net Received: from [144.76.185.252] ([144.76.185.252:46260] helo=mail01.nexxes.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/71-03694-B1981BA5 for ; Tue, 20 Mar 2018 17:20:12 -0500 Received: from [192.168.178.24] (xdsl-87-78-250-126.netcologne.de [87.78.250.126]) (Authenticated sender: db220660-p0g-1-m5x-1) by mail01.nexxes.net (Postfix) with ESMTPSA id D57BF86036D for ; Tue, 20 Mar 2018 23:20:08 +0100 (CET) To: internals@lists.php.net References: Message-ID: Date: Tue, 20 Mar 2018 23:20:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Weird destructor call order on stream wrappers From: php@dennis.birkholz.biz (Dennis Birkholz) Hello again, Am 20.03.2018 um 23:13 schrieb Dennis Birkholz: > (I also appended both example files as I don't know how long snippets at > 3v4l.org persist) the list does not allow attachments, so inline. If this does not work, 3v4l must suffice. Greets, Dennis id = self::$counter++; } public function stream_open($path, $mode, $options, &$opened_path) { echo "({$this->id}) stream_open()\n"; return true; } public function stream_write($data) { echo "({$this->id}) stream_write()\n"; return \strlen($data); } public function stream_flush() { echo "({$this->id}) stream_flush()\n"; if ($this->id === 1) { Lalala::blubb(); } else { Foobar::blubb(); } return true; } public function stream_close() { echo "({$this->id}) stream_close()\n"; return true; } public function __destruct() { echo "({$this->id}) __destruct()\n"; } } \stream_wrapper_register('test', MyStreamWrapper::class); if (($handle = \fopen('test:///foobar', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle, 'test') === false) { throw new \RuntimeException("Failed to write to file"); } if (\fclose($handle) === false) { throw new \RuntimeException("Failed to close file"); } if (($handle2 = \fopen('test:///blubb', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle2, 'test') === false) { throw new \RuntimeException("Failed to write to file"); }