Try to call __toString on objects passed to `file_put_contents`

Before it would just check to see if it was an object, raise a warning and then return false. Now it checks for a `__toString` method first, failing if it doesn't exist.

Fixes #1852