Repository navigation
Conversation
Several pull requests against 5.x-dev need to describe their breaking changes in the update guide. Create it with one placeholder per pending change, so that these pull requests fill in their own section without conflicting with each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
encrypt(), decrypt(), generateKey() of CipherInterface and the ciphers, and the corresponding Crypt methods had no scalar or return types, so null or other non-string input was silently coerced. Declare the types; this breaks implementers of the interface and is therefore a 5.0 change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary of Changes
CipherInterface::encrypt()/decrypt()/generateKey(), their implementations andCrypt::encrypt()/decrypt()/generateKey()/setKey()/genRandomBytes()have no scalar parameter or return types, sonullor other non-string input is silently coerced. Adding types to the interface breaks every implementer, hence 5.x.New signatures:
CipherInterfaceandCipher\Crypto,Cipher\OpenSSL,Cipher\Sodium:encrypt(string $data, Key $key): string,decrypt(string $data, Key $key): string,generateKey(array $options = []): KeyCrypt:encrypt(string $data): string,decrypt(string $data): string,generateKey(array $options = []): Key,setKey(Key $key): static,genRandomBytes(int $length = 16): stringThe constructor of
Cryptis left to #33. The removal of the deprecatedSodium::setNonce()is a separate PR; the future ofCipher\OpenSSLis still open.Testing Instructions
New
Tests/NativeTypesTest.phpchecks the declared return types via reflection and thatnulldata / a non-numeric length now raiseTypeError(fails before the change).Documentation Changes Required
docs/v4-to-v5-update.md: new section "Native parameter and return types" (fills its placeholder).Depends on #45 (creates the update guide; this branch contains its commit until it is merged).
Related to #38 (4.x): it changes the doc blocks of the same method signatures, so expect small conflicts when 4.x-dev is merged into 5.x-dev; the result needs both changes.
🤖 Generated with Claude Code