Skip to content

verifyAll() returns how many checks it verified - #154

Merged
rasuvaeff merged 5 commits into
masterfrom
feat/verifyall-check-count
Oct 10, 2026
Merged

rasuvaeff merged 5 commits into
masterfrom
feat/verifyall-check-count

Conversation

@rasuvaeff

Copy link
Copy Markdown
Owner

Fixes #153

What

Understudy::verifyAll() now returns int<0, max> — how many checks it verified — instead of void, so a runner adapter can count real assertions instead of a flat one per test (understudy-phpunit's assertPostConditions() does addToAssertionCount(1) whether the test armed one expectation or fifteen).

One check, precisely

  • an expectation carrying a claim (expect(), or times() on a stub);
  • a plain stub under strictStubs, where its use is what is checked;
  • an ordering constraint over expectations that declared one (per context);
  • an armed protocol, whose completeness is checked here.

A failed check throws, so the number only ever counts checks that passed. Checks verify() made earlier are not part of it: those answered at their own call sites, and verifyAll() does not re-decide them.

Compatibility

void → int is source-compatible for every existing caller: the method answered nothing before, so no caller could have read the answer, and Understudy is final, so no override shadows it. composer bc-check -- --from=v1.0.1 agrees:

No backwards-incompatible changes detected

The compatibility policy in both READMEs previously said "retyping an existing public member is a major-version change", which would have made this a 2.0 for a change no caller can observe. The policy now says a return type may be widened in a minor release where no caller can observe the change (and the same reasoning admits a parameter widened to a supertype every existing argument already satisfies); narrowing is never minor. The paragraph quotes this very change as its first application.

Notes for reviewers

  • checkOrdering() split into orderedExpectations() (the collector) + orderingFailure() (the renderer), because the count needs to know whether an ordering constraint existed without re-walking states. allVerified() keeps its behaviour: orderingFailure(orderedExpectations($state)).
  • Counting happens where the checks happen — failuresIn() returns array{list<VerificationFailure>, int<0, max>} now — counted by what is checked, not what passed: a failed check throws before the number exists anyway.
  • docs/src/api/** regenerated with make docs-api; the wide diff is the catch-up of version strings and satellite references from the already-committed docs/.api-workspace/composer.lock move, plus the real verifyAll() docblock change.
  • Adapter PRs (understudy-phpunit counting max(1, n), understudy-testo metric +n) follow once this merges; the adapter contract suites in this repo's CI run against core HEAD either way.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f473cc3-01ec-40d0-a692-1c8163e92610

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…d minor

The compatibility policy amended in this PR admits widening a return type
where no caller can observe the change; teach the gate to recognise exactly
that case: every finding must be a 'changed from void to the non-covariant'
widening, the named class must reflect as final against the checkout, and
the top CHANGELOG heading must be a minor above the latest tag. Anything
else still fails. CHANGELOG declares 1.1.0 - the minor this ships in.
@rasuvaeff
rasuvaeff merged commit 9f93626 into master Oct 10, 2026
26 checks passed
@rasuvaeff
rasuvaeff deleted the feat/verifyall-check-count branch October 10, 2026 19:41
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.

verifyAll() should report how many checks it verified (double PR #12)

1 participant