uuid
uuid copied to clipboard
Return type of Ramsey\Uuid\Uuid::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize()
Deprecation Issue in PHP8.1
Description
Deprecated: Return type of Ramsey\Uuid\Uuid::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /wayfair/data/www/composer-packages/ramsey/uuid/src/Uuid.php on line 216 PHP Deprecated: PHPUnit\Runner\DefaultTestResultCache implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /wayfair/data/www/composer-packages/phpunit/phpunit/src/Runner/DefaultTestResultCache.php on line 34
Screenshots or output
Environment details
- version of this package: 3.9.6
- PHP version: 8.1
- OS: e.g. Windows 10, Linux (Ubuntu 18.04.1), macOS Catalina (10.15.3)
Additional context
This is the same issue as #399 and requires a change to the interface, which I can’t do in minor- or patch-level releases when following semver.
So what is the approach then?
For now I created a file in my repository and used it instead, tests pass, but better could be new major version
<?php
namespace Radzi/Cicinas;
use Ramsey\Uuid\UuidInterface;
interface FixedUuidInterface extends UuidInterface {
public function __serialize(): array;
public function __unserialize(array $data): void;
}
That sounds like a good approach. I’m working on version 5 that will solve this problem, since I can do BC breaks then.
#[\ReturnTypeWillChange]
@ramsey can't you add this for now to surpass the deprecation warning in minor version? > #[\ReturnTypeWillChange]
Yep. Looks like we can add the mixed
return type now that the lowest version is PHP 8. Would you like to submit a PR for this?
jsonSerialize returns :string now and so there's no problem at 4.x. You wish to release 3.9.x with a fix ?
3.9.x still supports PHP 5.4 and 7.x. What change could we make to jsonSerialize()
in 3.9.x that would support all those versions?
@ramsey is there any timeline for a v5 release?
This bug is fixed in version 3.9.7.
Legend. Cheers.
I have error:
Return type of BN\BN::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice