On Sun, May 17, 2015 at 7:10 AM, Rowan Collins <rowan.coll...@gmail.com> wrote:
> On 17 May 2015 00:44:03 BST, Levi Morrison <le...@php.net> wrote:
>>On Sat, May 16, 2015 at 2:17 PM, Rowan Collins
>><rowan.coll...@gmail.com> 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:
>>
>><?php
>>
>>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.
>
> An interesting example. However, the behaviour would still have changed if 
> TypeException was a sub-class of Exception, because it would echo "caught" 
> rather than "handled" (a trivial difference in this trivial example, but 
> there's no reason to assume the actual code would be the same in both cases).

Yes, it would have changed. As I have said several times now there is
a BC break no matter what we do here. My point is that since it's a BC
break no matter what we should trust that people who said `catch
(Exception)` rather than assume that they didn't actually want to
catch all exceptions. They did, after all, write `catch (Exception)`
and exceptions are documented such that all exceptions must extend
Exception. We shouldn't assume that they didn't mean it and work
around it. For people who didn't mean it and they now get slapped:
that's good too because it forces them to change their logically
incorrect code. How is that a bad thing?

In this specific case we have broken all code out there. This is a
point that I am fairly sure people didn't fully understand in voting.
The idea that "we avoided a BC break by introducing a new exception
hierarchy" was simply untrue but that's essentially the idea they
voted on. Of course most people are going to vote to avoid BC break if
possible. This is why I think we certainly have grounds to revote.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to