this PR fixes bug introduced in #439. Previously (1.x) loose comparison was used to check if body is empty, now (2.0) strict comparison is used. This changes behaviour when JSON body is empty. In that case the Request::getBody() returns null. It is then passed to json_decode() which fails with error:
TypeError: json_decode(): Argument #1 ($json) must be of type string, null given
I fixed it with adding explicit $body !== null check. I also added test which can trigger this error. Some changes in RequestTest was needed though to tests work correctly (reset of some variables to default state).
Hi,
this PR fixes bug introduced in #439. Previously (1.x) loose comparison was used to check if body is empty, now (2.0) strict comparison is used. This changes behaviour when JSON body is empty. In that case the
Request::getBody()
returnsnull
. It is then passed tojson_decode()
which fails with error:I fixed it with adding explicit
$body !== null
check. I also added test which can trigger this error. Some changes inRequestTest
was needed though to tests work correctly (reset of some variables to default state).