Skip to content

Normalize enum/exception coverage conventions #481

Description

@armanist

Summary

Normalize enum and exception coverage conventions across the core packages so coverage reporting is consistent and intentional.

Problem

Current codebase has inconsistent patterns:

  • enum-like classes are mixed (final vs non-final, private constructor missing in some, @codeCoverageIgnore used inconsistently)
  • exception classes appear inconsistently covered (some only indirect coverage, some uncovered)

This makes coverage numbers noisy and hard to interpret.

Scope

  • apply one enum pattern to constant-holder classes
  • apply one exception coverage/testing policy
  • keep changes focused and backward-compatible

Proposed standards

Enums (constant-holder classes)

  • use final class
  • add private function __construct()
  • add @codeCoverageIgnore for pure constant-holder enums
  • do not add tests that only reference constants

Exceptions

  • do not blanket-ignore all exception classes
  • add focused unit tests for exception factory behavior (message/code/previous) where logic exists
  • for trivial pass-through exception wrappers, keep one consistent policy (either intentionally ignored or intentionally uncovered), documented in repo

Initial candidates to normalize

  • src/App/Enums/ExceptionMessages.php
  • src/Auth/Enums/AuthKeys.php
  • src/Database/Enums/Key.php
  • src/Database/Enums/Relation.php
  • src/Database/Enums/Type.php
  • src/Environment/Enums/Env.php
  • src/Http/Enums/ContentType.php
  • src/Http/Enums/StatusCode.php
  • src/Paginator/Enums/Pagination.php
  • src/Cron/Enums/ExceptionMessages.php (verify structure consistency)

Acceptance criteria

  • enum-like constant-holder classes follow one shared structure
  • exception coverage policy is applied consistently in code/tests
  • no behavior regressions
  • validation passes:
    • vendor/bin/phpunit
    • composer phpstan
    • composer cs:check

Reference

  • local proposal: docs/tickets/enum-exception-coverage-policy.md

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions