This package follows the InitPHP org-wide contribution guide. Please read it first — everything below is in addition to that guide, not a replacement for it.
git clone https://github.com/InitPHP/Encryption.git
cd Encryption
composer installRequired PHP extensions for the test suite:
ext-opensslext-sodium
The CI pipeline runs three checks. Run them locally before pushing — every PR must pass all three.
| Command | What it does |
|---|---|
composer test |
Run the PHPUnit suite. |
composer phpstan |
Static analysis at level 8. |
composer cs-check |
Verify PSR-12 compliance (read-only). |
composer cs-fix |
Apply PSR-12 fixes automatically. |
composer qa |
Run cs-check, phpstan and tests in sequence. |
- Unit tests live in
tests/Unit/and must not require any I/O or extension state beyond whatext-opensslandext-sodiumprovide. - Integration tests live in
tests/Integration/and may pin golden ciphertexts for backwards-compatibility verification. - A bug fix PR must include a regression test that fails on
mainand passes with the fix applied. - Cover both the happy path and the failure paths (tampered ciphertext, invalid configuration, missing key, etc.).
Any change that affects cryptographic primitives, key derivation, ciphertext format, or the trust boundary between an attacker and the plaintext requires:
- An explicit reviewer note in the PR description describing the threat model.
- A test that exercises the failure path (e.g. tampered HMAC must be rejected).
- A
CHANGELOG.mdentry under the appropriate section.
If you believe you have found a vulnerability, do not open a public issue or PR. Follow the security policy instead.
We use Conventional Commits. Typical scopes for this repository:
openssl— changes toOpenSSLhandlersodium— changes toSodiumhandlerbase— changes toBaseHandlerfactory— changes toEncryptdocs,test,ci,chore— as in the org guide
Example:
fix(openssl): handle openssl_decrypt failure before unserialize
openssl_decrypt() returns false on failure, which then caused
unserialize(false) to throw a TypeError on PHP 8.x. Detect the false
return and throw EncryptionException with a meaningful message.
Closes #NN