Skip to content

Commit 5fd6274

Browse files
committed
minor #58094 Use Stringable whenever possible (fabpot)
This PR was merged into the 7.2 branch. Discussion ---------- Use Stringable whenever possible | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | n/a | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- 06b49968a5 Use Stringable whenever possible
2 parents 1579e3d + 8359de7 commit 5fd6274

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(mixed $data = null, int $status = 200, array $header
4040
{
4141
parent::__construct('', $status, $headers);
4242

43-
if ($json && !\is_string($data) && !is_numeric($data) && !\is_callable([$data, '__toString'])) {
43+
if ($json && !\is_string($data) && !is_numeric($data) && !$data instanceof \Stringable) {
4444
throw new \TypeError(\sprintf('"%s": If $json is set to true, argument $data must be a string or object implementing __toString(), "%s" given.', __METHOD__, get_debug_type($data)));
4545
}
4646

0 commit comments

Comments
 (0)