Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87036 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99618 invoked from network); 5 Jul 2015 21:45:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2015 21:45:17 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.50 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wg0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:34922] helo=mail-wg0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/D5-21549-D65A9955 for ; Sun, 05 Jul 2015 17:45:17 -0400 Received: by wgjx7 with SMTP id x7so124968959wgj.2 for ; Sun, 05 Jul 2015 14:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Mzx0vHvcWFmpxS3TK79nAmQ4xBrrXWHW3NZexu+MRkE=; b=USIOxgFC0BnT/xzgdMinXFI2EK0ev+yAuJeEaCmDaBeUNO8XYONzKRiEXub0PTO7gz MZQKLlUXe0VHFcar0aAoUgjn9tBiRm3P0RV57AoJUqbRiCqE//ZySEyoFjRDbJTvazM3 cOxQ2RBCK3w5bYugNGmYgOMRCtknNySTutnl0WiRq5I1upsvIJZwWrlsg81LSbKeubhE xw38ynkSInZWKM9ggypndoH256y5Fl4jAH3EZW5uKFlRSMdexmJmkeJ4/L3HbjV/va5m LYp8i4VOimvFF+t64fN9n4bQ1Lp+Fx7QKIceI8ATuvfN6jGltfoIDl8D5HRkAkRuR9/6 cSfA== MIME-Version: 1.0 X-Received: by 10.194.82.38 with SMTP id f6mr39151853wjy.16.1436132714091; Sun, 05 Jul 2015 14:45:14 -0700 (PDT) Received: by 10.27.79.200 with HTTP; Sun, 5 Jul 2015 14:45:14 -0700 (PDT) In-Reply-To: References: <1435240516.15676.7.camel@kuechenschabe> <1436127623.5633.4.camel@kuechenschabe> <559994AB.3090102@gmail.com> Date: Sun, 5 Jul 2015 23:45:14 +0200 Message-ID: To: Stanislav Malyshev Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , PHP internals Content-Type: multipart/alternative; boundary=047d7bf0bfc2461d4a051a27b490 Subject: Re: [PHP-DEV] Allow exceptions in __toString() From: nikita.ppv@gmail.com (Nikita Popov) --047d7bf0bfc2461d4a051a27b490 Content-Type: text/plain; charset=UTF-8 On Sun, Jul 5, 2015 at 10:51 PM, Nikita Popov wrote: > On Sun, Jul 5, 2015 at 10:33 PM, Stanislav Malyshev > wrote: > >> Hi! >> >> >>> I can see your concern here -- however this is nothing specific to >> >>> exceptions thrown from __toString(). There is are a number of ways you >> >>> can end up in this situation, the two most common being: >> >> >> >> I summarize this a bit freely as "We already have places which are hard >> >> to understand an predict, so let's add more!" >> >> >> > >> > That, or "Let's not be hypocrites". >> >> I don't think the position of "let's not add more unpredictable behavior >> to the engine" is adequately described as "hypocrite". We know there are >> interruption problems and such in the engine, we know some of them are >> hard to fix. However, adding a different class of those doesn't make it >> better in any way. If we find a solution that allows us to not introduce >> new unpredictable behaviors - I'm all for it, it's great. Maybe the code >> that allows to throw exceptions the same way we do with errors, maybe >> some way to not get unpredictable results on conversions. But we can't >> just ignore it because there are other problems in the engine too. > > > Sorry, I just find it somewhat weird that we consider some of the > exceptions generated as the result of __toString calls to be okay (error > handler exceptions), while others are considered to be too dangerous to > allow (direct exceptions). > > But maybe I just approached this from the wrong direction. Instead of > allowing exceptions in __toString in combination with some hardening of the > VM, maybe we should just convert the recoverable fatal errors __toString > currently throws to actual fatal errors? Not a huge fan of doing that, but > at least it's consistent. > I just realized that this wouldn't quite cut it, because our object to integer and object to float conversions currently throw notices, which can be converted to exceptions and to-int conversions at least are all over the place. Presumably it's not acceptable to change these notices to fatal errors. Furthermore the array-to-string conversion also throws a notice since 5.4, which can also result in an exception. While we approved an RFC (not implemented) to make this a recoverable error, I suspect making this a real fatal error will not be met with much enthusiasm. Nikita --047d7bf0bfc2461d4a051a27b490--