Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84633 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61202 invoked from network); 12 Mar 2015 12:33:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2015 12:33:19 -0000 Authentication-Results: pb1.pair.com header.from=cryptocompress@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cryptocompress@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.173 as permitted sender) X-PHP-List-Original-Sender: cryptocompress@googlemail.com X-Host-Fingerprint: 74.125.82.173 mail-we0-f173.google.com Received: from [74.125.82.173] ([74.125.82.173:36424] helo=mail-we0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/23-42021-F8781055 for ; Thu, 12 Mar 2015 07:33:19 -0500 Received: by wesw55 with SMTP id w55so16030910wes.3 for ; Thu, 12 Mar 2015 05:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=iSToGJSGl5GCEq5mIe0sTr72Kb7rfQVzu1jXeWqbcTE=; b=XAUR03EmiHv5amAClSkjqWJohagEuAD+XVpRkZdrOV9BkyhRmX2PywOBdOba4KscIQ Q88wYWEkWhq3Qws7Ndqt3R1BjgVcLtWpeqSBN+MAVufWZucYTho4FDHT3jeKIHYPF8bf 2LeRZ5agTlhaRN+A3T1KwC1XvK3slRQa1bEUcFjw7cXj9U5qFTtT3cdRDo9cDyttCJC5 DhvS0Wjn8JYhCDM7EDviySL1jJUBvl9YBAaywBD0U5K5zpbDAmFNNLitqXe2qAjI7PmP +ExKUvaPRNya//r4RinNXngHQF/pX4RtmfEWXdiXTV3U03vmhv+ABlJQLJcoh2zxq8F1 V0hg== X-Received: by 10.180.77.199 with SMTP id u7mr27335967wiw.42.1426163596738; Thu, 12 Mar 2015 05:33:16 -0700 (PDT) Received: from [192.168.1.115] (mnch-5d856805.pool.mediaWays.net. [93.133.104.5]) by mx.google.com with ESMTPSA id r3sm9865416wjw.7.2015.03.12.05.33.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Mar 2015 05:33:15 -0700 (PDT) Message-ID: <5501878A.50506@googlemail.com> Date: Thu, 12 Mar 2015 13:33:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: PHP Developers Mailing List References: <6D.2C.32765.10EC0055@pb1.pair.com> <5501759A.3010403@googlemail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] static constructor From: cryptocompress@googlemail.com (Crypto Compress) Am 12.03.2015 um 12:33 schrieb Johannes Ott: > Am 12.03.2015 um 12:16 schrieb Crypto Compress: >> Hello Johannes, >> >> class Foo { >> private static function __static() { >> throw new Exception("boom"); >> } >> } >> >> while(true) { >> try { >> $foo = new Foo; >> } catch (Exception ex) {} >> } >> >> Would this code be valid? > Have to think about this issue, but on the first look I would say yes! > > Because the meaning of the static constructor is to do some necassary > initialize for the class it should be able to throw an Exception if it > cannot do it's work correctly. For example if it needs to read some > configuration from a Database and is not able to connect. > > For the caller I although would say, that the error inside the static > constructor should be catchable, for the simple fact that every Error > should be catchable for user-errorhandling. > > What is your point of view for this? I'm open for discussion about this. > > Regards If it's valid code then caching thrown exception and rethrow as wrapped-inner-exception on each subsequent access on Foo, seems feasible. I like the idea but cannot wrap my head around this.