Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 3.47 KB

CONTRIBUTING.md

File metadata and controls

110 lines (75 loc) · 3.47 KB

Contributing

Contributions are welcome. Please follow the workflow below before opening a pull request.

Scope

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 the is<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.

Supported PHP versions

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.

1. Fork

Fork Pharaonic/php-smart-enum on GitHub.

2. Clone

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.git

3. Install dependencies

composer install

4. Create a branch

Start from the line you are targeting:

git checkout 8.1.x
git pull upstream 8.1.x
git checkout -b fix/short-description

Recommended prefixes:

feature/
fix/
refactor/
test/
docs/

5. Run tests

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 above

All checks must pass. CI runs them on the branch's PHP version, on Linux and Windows, with the lowest and highest allowed dependencies.

6. Follow the coding style

  • PER coding style, enforced by Pint (composer format:check); composer format fixes 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 UnitEnum and BackedEnum deliberately.
  • Keep the trait small. Do not add internal services or abstraction layers until a real need exists.

7. Open a pull request

git push origin fix/short-description

Open 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.md under the line's next version, headed ## 8.N.p - Unreleased.
  • Update docs/ (the pharaonic.dev documentation) when the public API or usage changes.

Public API 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.

Code of Conduct

This project follows the Code of Conduct.

Security

Do not report security vulnerabilities through public issues. See SECURITY.md.