Repository navigation
Conversation
Without a cipher, Crypt falls back to the Crypto cipher, whose library is only suggested; without a key, it generates one that is never stored, so the data it encrypts cannot be decrypted by any other instance. Trigger a deprecation when either argument is omitted; both become required in 5.0. 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
new Crypt()/new Crypt($cipher)silently fall back to theCryptocipher (whose librarydefuse/php-encryptionis only suggested) and to a freshly generated key that is never stored, so data encrypted that way can never be decrypted by another instance. Making both arguments required is a BC break and is done for 5.0 in #33.This PR is the 4.x counterpart: the constructor keeps its signature and defaults, but triggers a deprecation (
trigger_deprecation(),symfony/deprecation-contractsadded torequire) when the cipher or the key is omitted.Testing Instructions
New tests in
CryptTest:testConstructorWithoutCipherOrKeyTriggersDeprecation(no arguments / no key / no cipher) expects the deprecation message; fails before the change.testConstructorDefaultsStillWorkshows thatnew Crypt()still encrypts and decrypts.Documentation Changes Required
docs/overview.md("Which cipher to use"): new paragraph saying both arguments should always be passed, that omitting them is deprecated, and why.Related to #33 (the 5.x removal of the defaults; it changes the same constructor docblock lines, so expect a small conflict when 4.x-dev is merged into 5.x-dev — #33's version wins).
🤖 Generated with Claude Code