[PHP-DEV] E_RECOVERABLE_ERROR for object to string conversion

I stumbled upon a difference in behavior between PHP >=7.0 and HHVM when it comes to object-to-string conversion for objects not implementing a `__toString` which caught me by surprise.

It's probably a pretty common scenario, especially for inexperienced PHP developers, as all it takes is to accidentally name your method `_toString()` or `toString()` rather than `__toString()`.

When trying to use an object which does not implement a __toString(), PHP will emit an E_RECOVERABLE_ERROR where HHVM throws an Error.
See https://3v4l.org/WtJff for a minimal example. HHVM's behavior makes more sense to me here.

To me, PHP's behavior is especially unexpected if you consider the behavior in https://3v4l.org/lF7gR where PHP *does* throw a (Type)Error because of the typehint. Note this example works if you change `$a` for an instance of something with a proper `__toString()`-method.

I searched through the discussions on the original 'Exceptions in the engine' RFC and couldn't find any mention of this specific case so I was wondering if anyone remembers if this was deliberately kept this way? I'm not sure if I have the skill to write a patch, I'm willing to try, but it'd be a waste of time if there is some good reason for having kept this an E_RECOVERABLE_ERROR I'm unaware of.

> Hi Internals,
>
> I stumbled upon a difference in behavior between PHP >=7.0 and HHVM when it comes to object-to-string conversion for objects not implementing a `__toString` which caught me by surprise.
>
> It's probably a pretty common scenario, especially for inexperienced PHP developers, as all it takes is to accidentally name your method `_toString()` or `toString()` rather than `__toString()`.
>
> When trying to use an object which does not implement a __toString(), PHP will emit an E_RECOVERABLE_ERROR where HHVM throws an Error.
> See https://3v4l.org/WtJff for a minimal example. HHVM's behavior makes more sense to me here.
>
> To me, PHP's behavior is especially unexpected if you consider the behavior in https://3v4l.org/lF7gR where PHP *does* throw a (Type)Error because of the typehint. Note this example works if you change `$a` for an instance of something with a proper `__toString()`-method.
>
> I searched through the discussions on the original 'Exceptions in the engine' RFC and couldn't find any mention of this specific case so I was wondering if anyone remembers if this was deliberately kept this way? I'm not sure if I have the skill to write a patch, I'm willing to try, but it'd be a waste of time if there is some good reason for having kept this an E_RECOVERABLE_ERROR I'm unaware of.