Skip to content

Refactor request matchers to objects with cassette-level scope (RequestMatcherInterface) #446

Description

@higidi

Idea

Today request matchers are plain PHP callbacks registered globally in Configuration. Two improvements have been proposed in PR #266:

  1. RequestMatcherInterface — make matchers typed objects instead of raw callbacks, improving type safety and IDE support.
  2. Cassette-scoped matchers — store matchers per cassette instead of globally, so different cassettes can use different matching strategies without global state changes.

Motivation

Complex matching scenarios (e.g. "match all requests to /product except when id=42, which should match on query string too") currently require a single global custom callback that encodes all the logic. Cassette-scoped matchers would allow per-request matcher overrides directly in the cassette definition.

BC break

Both changes are backwards-incompatible:

  • RequestMatcherInterface replaces the current callable type
  • Cassette-stored matchers change the cassette format

Target: 2.0 only.

Reference

See PR #266 for a prior implementation attempt. The PR is too old to merge directly — the codebase has changed significantly — but the concept is sound.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BC BreakThis issue or pull request breaks backwards compatibilityFeatureNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions