Skip to content

Conversation

@xyng
Copy link

@xyng xyng commented Aug 26, 2025

Description

Using this library in PHP ^8.1 causes this deprecation warning:

deprecated: 8192 :: Return type of Sanity\Transaction::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

This PR adds the mentioned annotation #[\ReturnTypeWillChange], which silences the deprecation without breaking compatibility to older PHP-Versions by specifying the return type.
The annotation is seen as a comment by older PHP-Versions.

What to review

jsonSerialized was annotated with #[\ReturnTypeWillChange] in these files:
lib/Path.php
lib/Selection.php
lib/Transaction.php

Testing

No deprecation warning present after applying the patch.

JsonSerializable got type annotations. Adding the annotation #[\ReturnTypeWillChange] silences that without breaking php 5.6 compatibility.
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