Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] cast Expression as string so it can be encoded #34569

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cast Expression as string so it can be encoded
because the `Expression` contains no public properties, when it is JSON encoded, it will always return '{}', which is unhelpful to us in debugging.
  • Loading branch information
browner12 authored Sep 28, 2020
commit 0caa369fddd2a6d8f2faf47e744e83ededde7039
6 changes: 5 additions & 1 deletion src/Illuminate/Testing/Constraints/HasInDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ protected function getAdditionalInfo($table)
*/
public function toString($options = 0): string
{
return json_encode($this->data, $options);
foreach ($this->data as $key => $data) {
$output[$key] = $data instanceof Expression ? (string) $data : $data;
}

return json_encode($output ?? [], $options);
}
}