Emit JSON errors from PHP Parser
Emit JSON errors from PHP Parser

The PHP parser had a bug here in that it presumed JSON encoding would
succeed (and there are reasons it might not). This checks the return
value of `json_encode` and emits a relevant error message if
appropriate. Before this, a triggering case would result in empty output
and an unhelpful error message from `JSON.parse` upstream in the Ruby
code.

codeclimate/codeclimate-duplication,codeclimate/codeclimate-duplication,codeclimate/codeclimate-duplication,codeclimate/codeclimate-duplication