[5.7] Fix(tester): TestResponse assertExactJson does not work for empty JSON objects #26353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved the problems mentioned in #25960 and #25769.
After the old decodeResponseJson directly operates on the response content json_decode($content, true), it is impossible to tell the difference between empty object and empty array.
Therefore, if we want to distinguish between empty object and empty array, we need to change the second parameter $assoc to false.
But that's not compatible with the logic that preceded it. The assoc array is resolved to stdclass.
So. for compatibility, I have json_decode($data, true) and json_decode($data, false); Only get json_decode($data, false); The empty object inside is thus compatible with the previous logic, and the bug is fixed.