grifart/enum
62.5
Adequate · 21 September 2026
495
lines of production code
PHP
primary language
4
measurements over time
What this system is
This system is a PHP library that provides a type-safe enumeration implementation, allowing developers to create and manage enum types with built-in validation. It offers an abstract base class and traits to simplify enum creation, while enforcing structural consistency and type safety through runtime checks. The library includes comprehensive test coverage and examples demonstrating migration from legacy constant-based patterns to more robust enum implementations.
How it got here
2017 — Initial release and validation
8 changes.
This period marks the initial release of the grifart/enum library, introducing the core Enum base class and AutoInstances trait for PHP 7.1+. The work focused on establishing a robust testing suite and enforcing structural consistency checks to ensure type-safe enumeration implementations.
2019 — Test coverage and migration examples
5 changes.
This period focused on expanding test coverage and providing migration examples for the Enum library. The work included adding regression tests for edge cases and creating detailed test suites that demonstrate how to migrate legacy code and refactor state machines using the new enum implementation.
Features
Initial release of grifart/enum library with CI and documentation
The grifart/enum library is now available as a standalone package, providing a type-safe enumeration implementation for PHP 7.1+. This release includes comprehensive documentation in the README, a MIT license file, and a PHPStan configuration for static analysis. Additionally, a GitLab CI pipeline is established to automatically test the library across PHP versions 7.2 through 8.1, ensuring compatibility and code quality.
(repo-wide) · high confidence
Introduction of Enum base class and AutoInstances trait
The library now provides an abstract \Enum\ class and an \AutoInstances\ trait to simplify the creation of enumeration types. The \Enum\ class offers methods like \fromScalar()\ to create instances from scalar values, \getAvailableValues()\ to list all defined values, and \\_\_toString()\ for string representation. The \AutoInstances\ trait allows developers to automatically generate enum instances from class constants, reducing boilerplate. New exception types (\UsageException\, \RuntimeException\, \MissingValueDeclarationException\, \ReflectionFailedException\) are introduced to handle errors such as missing value declarations or reflection failures.
src · high confidence
Behavioural changes
Enforced consistency checks for enum declarations
The library now validates enum structures at runtime to ensure correctness. A new ConsistencyChecker enforces that enum classes are either abstract or final, that all declared scalar values have corresponding constant definitions, and that required PHPDoc @method annotations are present. These checks are performed during registration via InstanceRegister, helping developers catch configuration errors early.
src/Internal · high confidence
Test coverage
Added PHP test for loyalty program example; Added Test Bootstrap Configuration; Added consistency tests for enum validation rules; Added regression tests for enum validation and edge cases; Added tests for adding behavior to enums; Added tests for enum reflection and value retrieval; Added tests for enum scalar value access and comparison behaviors; Added tests for migrating legacy code to Grifart Enum; Added tests for order state refactoring examples.
Dependencies
Updated dev dependencies and added PHPStan tooling
The project's development dependencies have been updated: nette/tester was upgraded from ^1.7.0 to \~2.4.2, and PHPStan (along with phpstan-strict-rules and grifart/phpstan-oneline) was added to require-dev. Additionally, Composer scripts for verification and testing were added, and the PHP version requirement was set to \>=7.2.0.
(dependencies) · medium confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 64 → 62 (-2.0)
- Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 100 → 99 (-0.9)
- Architecture 69 → 69 (+0.0)
- Maturity 50 → 50 (+0.0)
- Readiness 74 → 64 (-9.7)
- Security 100 → 100 (+0.0)
Resolved (6)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
- LLM evaluation failed
- No exposed public API
- Test reliability not included
- dormant codebase — no living knowledge left to concentrate
New (5)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- No dependency advisory monitoring
- TodoComment (src/Internal/ConsistencyChecker.php)
- TodoComment (src/Internal/ConsistencyChecker.php)
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
grifart/enum was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 0bce28aaee19314f5dccf60eead35fa6ca9ab24a — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-fa71c66cabd8.