Conversation
…n]serialize() methods ... in light of the PHP 8.1 deprecation of the `Serializable` interface. For classes which implement the `Serializable` interface and need to support both PHP < 7.4 as well as PHP >= 8.1, the only way to avoid a deprecation warning is by implementing both the `Serializable` interface as well as the PHP 7.4 magic `__[un]serialize()` methods. In that case, the sniff should stay silent as the code is cross-version compatible, as for PHP < 7.4, the `Serializable` interface methods will be used to serialize the object, while for PHP 7.4 and higher, the magic methods will be used. Includes unit tests. Fixes 1310
This was referenced Mar 9, 2022
wimg
approved these changes
Apr 14, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
... in light of the PHP 8.1 deprecation of the
Serializableinterface.For classes which implement the
Serializableinterface and need to support both PHP < 7.4 as well as PHP >= 8.1, the only way to avoid a deprecation warning is by implementing both theSerializableinterface as well as the PHP 7.4 magic__[un]serialize()methods.In that case, the sniff should stay silent as the code is cross-version compatible, as for PHP < 7.4, the
Serializableinterface methods will be used to serialize the object, while for PHP 7.4 and higher, the magic methods will be used.Includes unit tests.
Fixes #1310
Related to #1299