Skip to content

ForwardingTargetMismatch ​

Rasuvaeff\Understudy\Exception\ForwardingTargetMismatch

Class — Package: rasuvaeff/understudy — Source — Version: v1.1.0-1-g6ed023f

Extends: InvalidArgumentException

Implements: Stringable, Throwable, Exception\UnderstudyError

The instance offered as a forwarding target does not satisfy what the double stands in for.

Methods ​

understudyTarget() ​

php
static understudyTarget(non-empty-string $label): self

Builds the error for forwarding to another understudy.

missingContract() ​

php
static missingContract(
    non-empty-string $label,
    class-string $contract,
    string $given,
): self

Builds the error for a forwarding target missing a contract.

alreadyInline() ​

php
static alreadyInline(
    non-empty-string $label,
    class-string $current,
    class-string $given,
): self

Builds the error for re-pointing a double that already forwards inline.

  • $label — the double's own name in reports
  • $current — the class whose bodies the double already runs
  • $given — the class of the instance offered instead

The state of the first donor was copied onto the double, and a copy cannot be taken twice: a readonly property is initialized, and whatever the inline calls have written since would be overwritten by a second donor's reading. Re-pointing is refused rather than silently leaving the double running the first donor's state against the second one's instance.