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

PHP 8.1: Magic methods replacing Serialize interface are not implemented #384

Closed
remorhaz opened this issue Aug 17, 2021 · 5 comments
Closed
Labels

Comments

@remorhaz
Copy link

Description

I'm getting the deprecation notice:

Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)
/.../vendor/ramsey/uuid/src/Uuid.php:41

I guess that it's enough just to add forementioned magic methods to get rid of message.

Steps to reproduce

In my case, I'm just creating an UuidFactory instance.

Environment details

  • version of this package: 4.2.1
  • PHP version: 8.1.0 beta2
@remorhaz remorhaz added the bug label Aug 17, 2021
@ramsey
Copy link
Owner

ramsey commented Aug 17, 2021

Thanks for reporting. Commenting to link this to #378

@ramsey
Copy link
Owner

ramsey commented Sep 24, 2021

This is fixed in version 4.2.2.

@ramsey ramsey closed this as completed Sep 24, 2021
@remorhaz
Copy link
Author

The problem with Uuid class is gone, thank you. But it still exists when I try to $this->createStub(UuidInterface::class) in PHPUnit - because there're still no magic methods in UuidInterface (see phpunit#4786 issue).

In the same time, UuidInterface exposes magic __toString() method; maybe it would be wise to expose magic serialization methods, too? In fact, they are direct replacement for the deprecated Serializable interface.

@ramsey
Copy link
Owner

ramsey commented Sep 25, 2021

Unfortunately, I can't add anything to the UuidInterface interface without breaking BC. If I change the interface, I need to bump the library version to 5.0.0, but at the same time, this means that anyone who continues to use the 4.x series on PHP 8 will end up seeing errors.

I'm not sure what is the correct approach.

This conversation is also somewhat related, since it involves versioning changes: 3c1ce39#commitcomment-57044641

@DavidGarciaCat
Copy link

DavidGarciaCat commented Jan 31, 2024

Hello @ramsey

May I ask why there is a problem with releasing version 5.0.0 (which will fix this deprecation notice)?

Previous and existing projects will keep using version 4, so it should not be a BC issue as far as they use the previous version, and if developers want to upgrade to a new major version, it's expected to have BC, and they will need to be fixed, right?

At the moment, I am getting the same deprecation notice when running PHPUnit tests and having installed this vendor via the Doctrine UUID bundle (https://github.com/ramsey/uuid-doctrine/).

  1x: Mock_UuidInterface_5306abad implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)
    1x in ServiceNameTest::testMethodName from App\Tests\Other\Namespace

I hope you can give some feedback here.

Thanks,

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

3 participants