Skip to content

Allow assertMatchesJsonSnapshot to accept any JSON-serializable value#216

Merged
freekmurze merged 1 commit intospatie:mainfrom
LuckyWindsck:luckywindsck/widen-parameter-type
Jul 2, 2025
Merged

Allow assertMatchesJsonSnapshot to accept any JSON-serializable value#216
freekmurze merged 1 commit intospatie:mainfrom
LuckyWindsck:luckywindsck/widen-parameter-type

Conversation

@LuckyWindsck
Copy link
Copy Markdown
Contributor

This PR removes the strict type annotation from the $actual parameter in assertMatchesJsonSnapshot() to allow any JSON-serializable value, including JsonSerializable objects.

The underlying JsonDriver already accepts mixed input, so this change relaxes the input constraint to better reflect its capabilities. It also improves consistency with other assertMatches*Snapshot methods, which do not restrict input types.

@LuckyWindsck
Copy link
Copy Markdown
Contributor Author

Related commits for parameter types:

  1. 04b9f69: $actual -> array|string $actual
  2. d1ebc83: array|string $actual -> array|string|null|int|float|bool $actual

Related Issues / PRs:

@freekmurze freekmurze merged commit 4d35654 into spatie:main Jul 2, 2025
17 checks passed
@freekmurze
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants