Skip to content

Extract shared rule logic into AbstractTypeCoverageRule - #98

Merged
TomasVotruba merged 1 commit into
mainfrom
abstract-type-coverage-rule
Oct 7, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
abstract-type-coverage-rule

Conversation

@TomasVotruba

Copy link
Copy Markdown
Owner

The four coverage rules (return, param, property, constant) were ~90 % identical copy-paste: same constructor, same getNodeType(), same processNode() flow (full-path guard, normalize, measure mode, enabled check, format errors).

This extracts the shared flow into AbstractTypeCoverageRule. Each concrete rule now only declares what differs:

  • collector class
  • error message + identifier
  • measure message
  • required type level

ConstantTypeCoverageRule additionally overrides shouldSkip() (PHP 8.3+ guard) and isEnabled().

Net -74 lines, behavior unchanged. getRequiredTypeLevel(): float is natively typed (cast from the float|int config value) so return type coverage stays over the required threshold; isEnabled() uses > 0, equivalent to the previous === 0 check for the non-negative level values.

Public ERROR_MESSAGE constants kept as-is, so existing tests are untouched. Tests, ECS, PHPStan and Rector pass.

@TomasVotruba
TomasVotruba force-pushed the abstract-type-coverage-rule branch from 3ac77b7 to 0bc8446 Compare October 7, 2026 11:48
@TomasVotruba
TomasVotruba merged commit dfb4a06 into main Oct 7, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the abstract-type-coverage-rule branch October 7, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant