Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86300 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19585 invoked from network); 19 May 2015 09:45:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 May 2015 09:45:14 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.171 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.214.171 mail-ob0-f171.google.com Received: from [209.85.214.171] ([209.85.214.171:35420] helo=mail-ob0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/E4-13816-9260B555 for ; Tue, 19 May 2015 05:45:13 -0400 Received: by obcus9 with SMTP id us9so7846230obc.2 for ; Tue, 19 May 2015 02:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=zcKODQhFYPSJmnFdAcPjPUasFOHNzOJas4mdCrsL8CU=; b=dMm7Zz3gn2GOAZ8hVPET9rKZsxFXYISk+tyG5Z2BAB/bCUMbnpuRkdopLlQfkVLQnv i1mhw4AllzJcXM7XzF/vsQw5j/9OwhJo4tISvYbEDON5CG1qpkl85el2FH+X1JCq8A9H 4wKcH+pXRC+ncEDL73YM32cL86UeEotaR6wTybb7XtQ7nQX50TvROM+wIb13NXZVDe5p +afqKq8WmzYDRyXrBHM1E82PjutNybKEjiR5X+gmEXQOyA3F5uPIIGlQSd2K3pth6FvZ P0SGZfwknPJ+M2cpLUzZDEzFsiZbAjLHJz47vFO0b1ipZ0qQLnjBZkYqZX7uo4we/yUJ udpQ== X-Received: by 10.60.59.106 with SMTP id y10mr23452253oeq.45.1432028710872; Tue, 19 May 2015 02:45:10 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.202.2 with HTTP; Tue, 19 May 2015 02:44:30 -0700 (PDT) In-Reply-To: References: <550DA4EE.2030903@php.net> <55410973.4010300@php.net> <55417C64.7000707@gmail.com> <5541B4D6.9060503@php.net> <55425D7E.6010803@gmail.com> <554D8F4D.9020903@gmail.com> <554D90CC.3040607@php.net> <5552E3EB.5010800@gmail.com> <5552E494.5070401@php.net> <5552FF58.8070807@php.net> <55575DCF.50801@gmail.com> <55578C61.3040408@gmail.com> <555796C0.2020002@gmail.com> <5557A5C6.5050701@gmail.com> Date: Tue, 19 May 2015 18:44:30 +0900 X-Google-Sender-Auth: UORZpKJ6Bv8qKg0f4oo8wJjN7Vw Message-ID: To: Levi Morrison Cc: Rowan Collins , internals Content-Type: multipart/alternative; boundary=089e015375009eae7405166c2a51 Subject: Re: [PHP-DEV] [VOTE] Exceptions in the engine From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e015375009eae7405166c2a51 Content-Type: text/plain; charset=UTF-8 Hi all, On Sun, May 17, 2015 at 8:44 AM, Levi Morrison wrote: > On Sat, May 16, 2015 at 2:17 PM, Rowan Collins > wrote: > > On 16/05/2015 20:15, Levi Morrison wrote: > >> > >> The difference is that as time goes on and I've written code for PHP 7 > >> I was hit by this issue. It's an even bigger issue than even I > >> realized during voting. How many people who voted on that issue have > >> played with the code from both scenarios? Few, I can't guarantee it > >> but given the historical precedent it's almost certainly true. > > > > > > Can you give an example of the issue you were hit with? A sample program > / > > scenario, where failure to catch an EngineException caused behaviour that > > was in some way worse than that under PHP 5? > > Here's a simplified example that illustrates one issue: > > > set_error_handler(function(){ > echo "Handled."; > }); > > function foo(callable $f) {} > > try { > foo("bar is not callable"); > } catch (Exception $e) { > echo "Caught."; > } > > echo "Done.", PHP_EOL; > > ?> > > In PHP 5 this prints "Handled.Done". Under PHP 7 this fails with: > > > Fatal error: Argument 1 passed to foo() must be callable, string given > > Note that if the TypeException had been caught by catch (Exception $e) > the program would have still been correct. This kind of setup exists > in PHPUnit for example; even if the test has some bad syntax or > failure the testing harness needs to continue. There are other valid > uses as well. > > The only way to make this work in both PHP 5 and 7 is to modify the > code, despite the program being 100% correct under PHP 5 and the > documented semantics. We should consider internal function error/exception also. New ZPP raises type error. produces E_WARNING Warning: mt_srand() expects parameter 1 to be integer, string given in - on line 2 If we are going to break codes, it is better to break code consistently. Is it possible treat each line enclosed by try {}? e.g. rather than For example, set_exception_handler(callback $callback [, bool $single_line_try_block = FALSE]) Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e015375009eae7405166c2a51--