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.
PHP 8.5 (>=8.5 <8.6) on this branch. Each PHP minor has its own 8.N.x release line. Keep code compatible with PHP 8.1 so fixes can be backported to every line.
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 installgit checkout -b fix/short-descriptionRecommended prefixes:
feature/
fix/
refactor/
test/
docs/
composer test # PHPUnit
composer analyse # PHPStan (level max)
composer lint # PHP_CodeSniffer (PSR-12)
composer check # all of the above
composer validate --strictAll checks must pass. CI runs them on the PHP version of the branch (PHP 8.5 on 8.5.x).
- PSR-12, enforced by
composer lint;composer formatfixes most issues. 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 and fill in the template.
- Keep each change focused.
- Add or update tests for every behavior change.
- Add an entry to
CHANGELOG.mdunderUnreleased. - 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.