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

Return type of Ramsey\Uuid\Uuid::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize() #439

Closed
pardeep26k opened this issue Aug 25, 2022 · 11 comments
Labels

Comments

@pardeep26k
Copy link

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

Uploading Screenshot 2022-08-25 at 12.30.54.png…

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

@pardeep26k pardeep26k added the bug label Aug 25, 2022
@ramsey
Copy link
Owner

ramsey commented Aug 25, 2022

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.

@Saltibarsciai
Copy link

Saltibarsciai commented Aug 25, 2022

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;
}

@ramsey
Copy link
Owner

ramsey commented Aug 25, 2022

That sounds like a good approach. I’m working on version 5 that will solve this problem, since I can do BC breaks then.

@pardeep26k
Copy link
Author

#[\ReturnTypeWillChange]

@ramsey can't you add this for now to surpass the deprecation warning in minor version? >
#[\ReturnTypeWillChange]

@ramsey
Copy link
Owner

ramsey commented Oct 4, 2022

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?

@vasilvestre
Copy link

jsonSerialize returns :string now and so there's no problem at 4.x. You wish to release 3.9.x with a fix ?

@ramsey
Copy link
Owner

ramsey commented Oct 7, 2022

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?

@NeilMasters
Copy link

@ramsey is there any timeline for a v5 release?

@ramsey
Copy link
Owner

ramsey commented Dec 19, 2022

This bug is fixed in version 3.9.7.

@ramsey ramsey closed this as completed Dec 19, 2022
@NeilMasters
Copy link

Legend. Cheers.

@DevelopByte
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants