Contributions are welcome. Please follow the workflow below before opening a pull request.
This package adds a small set of helpers to native PHP enums through the SmartEnum trait, plus one is<Case>() check per case resolved by __call(). The following are out of scope:
- Replacing or wrapping native methods (
cases(),from(),tryFrom()). - Other magic:
__callStatic(),__get(), or__call()behavior beyond theis<Case>()checks. - Enum base classes, code generation, Composer plugins, or source rewriting.
- Framework integrations (Laravel, Symfony, …). Those belong in separate packages.
- Runtime dependencies.
Please open an issue before proposing a new public method.
Each release line targets exactly one PHP version, and the branch name tells you which:
8.1.x → PHP 8.1
8.2.x → PHP 8.2
...
Code on a branch must not use syntax or functions introduced after that branch's PHP version. For a bug fix, start from the oldest line that has the bug; maintainers port it to the newer lines.
Fork Pharaonic/php-smart-enum on GitHub.
git clone https://github.com/YOUR_USERNAME/php-smart-enum.git
cd php-smart-enum
git remote add upstream https://github.com/Pharaonic/php-smart-enum.gitcomposer installStart from the line you are targeting:
git checkout 8.1.x
git pull upstream 8.1.x
git checkout -b fix/short-descriptionRecommended prefixes:
feature/
fix/
refactor/
test/
docs/
composer test # Pest
composer analyse # PHPStan (level max)
composer format:check # Pint; `composer format` fixes the style
composer security # Composer audit
composer check # composer validate --strict and all of the aboveAll checks must pass. CI runs them on the branch's PHP version, on Linux and Windows, with the lowest and highest allowed dependencies.
- PER coding style, enforced by Pint (
composer format:check);composer formatfixes it. declare(strict_types=1);in every PHP file.- Strict comparisons only (
===). Loose comparison needs a documented reason. - Do not assume every enum is backed: handle
UnitEnumandBackedEnumdeliberately. - Keep the trait small. Do not add internal services or abstraction layers until a real need exists.
git push origin fix/short-descriptionOpen the pull request against the version branch you started from, and fill in the template.
- Keep each change focused.
- Add or update tests for every behavior change.
- Add an entry to
CHANGELOG.mdunder the line's next version, headed## 8.N.p - Unreleased. - Update
docs/(the pharaonic.dev documentation) when the public API or usage changes.
The SmartEnum trait is mixed into users' own enums, so every public method name, parameter and return type is part of their code. Adding, renaming or changing a public method can break enums that declare a method with the same name, and changing a result can break callers. Public API changes need careful review and an issue discussion first; backward compatibility matters.
This project follows the Code of Conduct.
Do not report security vulnerabilities through public issues. See SECURITY.md.