Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84630 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54662 invoked from network); 12 Mar 2015 11:40:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2015 11:40:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.161 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.161 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.161] ([81.169.146.161:18777] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/F1-42021-34B71055 for ; Thu, 12 Mar 2015 06:40:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1426160448; l=3951; s=domk; d=kelunik.com; h=Content-Type:Cc:To:From:Subject:Date:References:In-Reply-To: MIME-Version; bh=FWG+OpGZ+nH5YBld8ElQWd8n9gifNrDBikE08Wq7Jis=; b=xqEwrQqds7eAvtSpOKewYUXijctMjmb8JTVJgtIhFwb+39aG4cXaY0qDzdb0GnTmXtU A5aGeRNYqn6SL5GH3CXEEGAF7qRihLO/gor083Wagx1SYMf4e8UHjjVrN6eR1HY5h2XFL iDANVK8qbH8QR2BPJyiS80JB7ZKhJRjWe4M= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtPnRR9w== X-RZG-CLASS-ID: mo00 Received: from mail-we0-f176.google.com ([74.125.82.176]) by smtp.strato.de (RZmta 37.3 AUTH) with ESMTPSA id L07779r2CBemxk7 (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) for ; Thu, 12 Mar 2015 12:40:48 +0100 (CET) Received: by wesw55 with SMTP id w55so15721294wes.3 for ; Thu, 12 Mar 2015 04:40:48 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.126.98 with SMTP id mx2mr129005445wib.18.1426160448371; Thu, 12 Mar 2015 04:40:48 -0700 (PDT) Received: by 10.27.222.1 with HTTP; Thu, 12 Mar 2015 04:40:48 -0700 (PDT) In-Reply-To: References: <6D.2C.32765.10EC0055@pb1.pair.com> <5501759A.3010403@googlemail.com> Date: Thu, 12 Mar 2015 12:40:48 +0100 Message-ID: To: Johannes Ott Cc: PHP Internals Content-Type: multipart/alternative; boundary=e89a8f838995eb0463051115da0b Subject: Re: [PHP-DEV] static constructor From: me@kelunik.com (Niklas Keller) --e89a8f838995eb0463051115da0b Content-Type: text/plain; charset=UTF-8 2015-03-12 12:33 GMT+01:00 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. > How would it behave for the second call? If the first initialize fails due to some exception, should that static constructor be executed again? > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Regards, Niklas --e89a8f838995eb0463051115da0b--