Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84629 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52979 invoked from network); 12 Mar 2015 11:33:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2015 11:33:29 -0000 X-Host-Fingerprint: 91.115.245.126 91-115-245-126.adsl.highway.telekom.at Received: from [91.115.245.126] ([91.115.245.126:17406] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/A1-42021-78971055 for ; Thu, 12 Mar 2015 06:33:27 -0500 Message-ID: To: internals@lists.php.net Date: Thu, 12 Mar 2015 12:33:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 References: <6D.2C.32765.10EC0055@pb1.pair.com> <5501759A.3010403@googlemail.com> In-Reply-To: <5501759A.3010403@googlemail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Posted-By: 91.115.245.126 Subject: Re: [PHP-DEV] static constructor From: mail@deroetzi.de (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 -- DerOetzi