Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86359 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68729 invoked from network); 23 May 2015 22:04:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 May 2015 22:04:11 -0000 Authentication-Results: pb1.pair.com header.from=benjamin.morel@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=benjamin.morel@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: benjamin.morel@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:36528] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 90/00-03126-459F0655 for ; Sat, 23 May 2015 18:04:05 -0400 Received: by wizk4 with SMTP id k4so18194681wiz.1 for ; Sat, 23 May 2015 15:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:thread-index:content-language; bh=VjdVI0ZEpBsdoPp2nTqo16k8hs6lbB0bOZg212LM9Q0=; b=Fi6oQL+yW3Dm5f17/RIQ10i2m83ph67Qby+z20ihxhWMuk2GtuDJoewXAvurq3sF4I hygQ9EYc66yIqyX3S0I25sXBLEvK8d5b4Bc9s6x6nL15THo6uaW3p734vkjV43jCsFhi dAGmYUMgYoloXssb8lcI9NS0uUsRN/9GfQ5fF42j0qwZqZ2v5MmT7CRwuIFOVkDDnsiP W2fLiLrhDk6jofjl9BOGD3/AzlG5NgASlABsqjSEnotutqRBipoHbAhSLXa6o/PzpUaQ uh9ReTI3gFTXI/OrZcSO+5rHmIBlGZOUGN5d8SFLGHcKcS60yN0dIo5clSlQIvLWiK5R 2Pqw== X-Received: by 10.180.218.195 with SMTP id pi3mr18936053wic.71.1432418641754; Sat, 23 May 2015 15:04:01 -0700 (PDT) Received: from BenjaminPC (fuv13-1-88-172-61-198.fbx.proxad.net. [88.172.61.198]) by mx.google.com with ESMTPSA id vy5sm9527845wjc.33.2015.05.23.15.04.00 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 23 May 2015 15:04:01 -0700 (PDT) To: =?UTF-8?Q?'Jakub_Kub=C3=AD=C4=8Dek'?= Cc: "'PHP Internals'" References: <000301d09526$ee7b0580$cb711080$@gmail.com> In-Reply-To: Date: Sun, 24 May 2015 00:03:49 +0200 Message-ID: <002101d095a4$5992c330$0cb84990$@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0022_01D095B5.1D1E7960" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQDFeEiRVHSznqdoLEDL5s4dwAb0JgF9yaEBn5Rm8gA= Content-Language: en-gb Subject: RE: [PHP-DEV] Allow __toString() to throw exceptions From: benjamin.morel@gmail.com ("Benjamin Morel") ------=_NextPart_000_0022_01D095B5.1D1E7960 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Hi Benjamin. =20 Hi Janub, =20 > I have a question: is there any reason to throw an exception from = __toString, other than a non-recoverable error, which would denote that = the object, which the __toString method is called on, does not have any = meaningful string representation? Because if not, core implementation = fully serves its purpose throwing Fatal error now, even if it is = non-standard way. =20 There are many reasons why you would want to throw an exception in = __toString(), just like in any other method.=20 Some of them may be recoverable, some may not be. Sorry I don=E2=80=99t = have an example at hand. =20 But even if the error is =E2=80=9Cnot recoverable=E2=80=9D, you still = want to leave your framework a chance to catch the uncaught exception to = present a nice error page to the user, and handle the error = appropriately (log, notify, etc.) =20 I=E2=80=99ve been thrilled to see that some move in the right direction = has already been made in PHP 7 : for example, calling a method on a NULL = value will throw an exception instead of resulting in a fatal error as = before. As I see it, fatal errors should be reserved to *really* unrecoverable = stuff, like memory exhausted or max execution time exceeded; the rest is = just annoyance. =20 Anyway it would be good to just reopen the bug for now to give it some = attention, as Zend Engine 3 is being written! =20 Cheers, Ben =20 ------=_NextPart_000_0022_01D095B5.1D1E7960--