Revert back to php_error_docref from php_error

It provides information which function generated an error.
Encode subclasses of stdClass as typed objects

It is not very useful to subclass stdClass in PHP, but can be
done. Previously such objects were encoded as anonymous objects. Now
as typed objects.