diff --git a/src/Codegen/TargetUnifier.php b/src/Codegen/TargetUnifier.php index c13275b..d52ad6f 100644 --- a/src/Codegen/TargetUnifier.php +++ b/src/Codegen/TargetUnifier.php @@ -671,7 +671,7 @@ private static function returnTypeBranches( ?\ReflectionType $type, \ReflectionClass $declaringClass, ): array { - if ($type === null) { + if (!$type instanceof \ReflectionType) { return [['mixed']]; } diff --git a/src/Codegen/TypeRenderer.php b/src/Codegen/TypeRenderer.php index add6174..e821567 100644 --- a/src/Codegen/TypeRenderer.php +++ b/src/Codegen/TypeRenderer.php @@ -33,7 +33,7 @@ private function __construct() {} */ public static function parameterType(?\ReflectionType $type, ?\ReflectionClass $declaringClass = null): string { - if ($type === null) { + if (!$type instanceof \ReflectionType) { return ''; } @@ -83,7 +83,7 @@ public static function acceptsMatcher(?\ReflectionType $type): bool */ public static function returnType(?\ReflectionType $type, ?\ReflectionClass $declaringClass = null): string { - return $type === null ? 'mixed' : self::resolveParent(self::render($type), $declaringClass); + return $type instanceof \ReflectionType ? self::resolveParent(self::render($type), $declaringClass) : 'mixed'; } /** @@ -150,7 +150,7 @@ private static function resolveParent(string $rendered, ?\ReflectionClass $decla */ private static function resolveSelf(string $rendered, ?\ReflectionClass $declaringClass): string { - if ($declaringClass === null) { + if (!$declaringClass instanceof \ReflectionClass) { return $rendered; } diff --git a/src/Defaults/DefaultFactories.php b/src/Defaults/DefaultFactories.php index 250db53..7a7f736 100644 --- a/src/Defaults/DefaultFactories.php +++ b/src/Defaults/DefaultFactories.php @@ -66,7 +66,7 @@ public function valueFor(string $requested, ?RuntimeContext $owner = null): ?arr $owner ??= Runtime::current(); $factory = $this->factoryFor($requested); - if ($factory === null) { + if (!$factory instanceof \Closure) { return null; } @@ -79,7 +79,7 @@ public function valueFor(string $requested, ?RuntimeContext $owner = null): ?arr $valueOwner = is_object($value) ? Runtime::ownerOf($value) : null; - if ($valueOwner !== null && $valueOwner !== $owner) { + if ($valueOwner instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext && $valueOwner !== $owner) { throw ContextOwnershipViolation::forDouble(); } diff --git a/src/Defaults/TypeDefaultResolver.php b/src/Defaults/TypeDefaultResolver.php index 7531885..9df147a 100644 --- a/src/Defaults/TypeDefaultResolver.php +++ b/src/Defaults/TypeDefaultResolver.php @@ -35,7 +35,7 @@ public static function forSignature( bool $nested = false, ?object $double = null, ): mixed { - if ($signature === null) { + if (!$signature instanceof \Rasuvaeff\Understudy\Codegen\MethodSignature) { return null; } diff --git a/src/Expectation/ArgumentFormatter.php b/src/Expectation/ArgumentFormatter.php index bec8437..e6aea7d 100644 --- a/src/Expectation/ArgumentFormatter.php +++ b/src/Expectation/ArgumentFormatter.php @@ -59,7 +59,7 @@ private function __construct() {} */ public static function scope(callable $render): mixed { - if (self::$aliases !== null) { + if (self::$aliases instanceof \SplObjectStorage) { return $render(); } @@ -82,7 +82,7 @@ public static function format(mixed $value, int $depth = 0): string return '…'; } - if (self::$aliases === null) { + if (!self::$aliases instanceof \SplObjectStorage) { return self::scope(static fn(): string => self::format($value, $depth)); } @@ -224,7 +224,7 @@ private static function formatObject(object $value, int $depth): string private static function alias(object $value): int { $table = self::$aliases; - \assert($table !== null); + \assert($table instanceof \SplObjectStorage); // `contains()` is deprecated as of 8.5; `offsetExists()` is the same // lookup under the name the language kept. diff --git a/src/Expectation/Expectation.php b/src/Expectation/Expectation.php index 9be07ee..f5855c0 100644 --- a/src/Expectation/Expectation.php +++ b/src/Expectation/Expectation.php @@ -168,7 +168,7 @@ public function hasCaptors(): bool */ public function setGuard(callable $guard, string $description): void { - if ($this->guard !== null) { + if ($this->guard instanceof \Closure) { throw InvalidCallSpecification::guardAlreadyNarrowed($this->method, $this->guardDescription); } @@ -189,7 +189,7 @@ public function setGuard(callable $guard, string $description): void */ private function acceptsGuard(array $args): bool { - if ($this->guard === null) { + if (!$this->guard instanceof \Closure) { return true; } @@ -349,7 +349,7 @@ public function matches(string $method, array $args): bool */ public function matchesArguments(array $args): bool { - if ($this->tailMatcher !== null) { + if ($this->tailMatcher instanceof \Rasuvaeff\Understudy\Matcher\TailMatcher) { $fixed = $this->argumentCount - 1; /** @var int<0, max> $fixed */ @@ -517,7 +517,7 @@ public function describeAgainst(array $args): string */ private function describeGuardAgainst(array $args): string { - if ($this->guard === null) { + if (!$this->guard instanceof \Closure) { return ''; } @@ -539,7 +539,7 @@ private function describeGuardAgainst(array $args): string */ private function acceptsGuardDefensively(array $args): bool { - \assert($this->guard !== null); + \assert($this->guard instanceof \Closure); try { return ($this->guard)(...$args); diff --git a/src/Invocation.php b/src/Invocation.php index 5cf832c..2d06c5f 100644 --- a/src/Invocation.php +++ b/src/Invocation.php @@ -181,7 +181,7 @@ public function recordOutcome(Outcome $outcome): void */ public function recordReturned(mixed $value): void { - if ($this->returnedState !== null || $this->outcome !== null) { + if ($this->returnedState !== null || $this->outcome instanceof \Rasuvaeff\Understudy\Outcome) { return; } @@ -201,7 +201,7 @@ public function recordReturned(mixed $value): void */ public function recordDiscardedReturn(): void { - if ($this->returnedState !== null || $this->outcome !== null) { + if ($this->returnedState !== null || $this->outcome instanceof \Rasuvaeff\Understudy\Outcome) { return; } @@ -226,7 +226,7 @@ public function isReturnDiscarded(): bool */ public function recordThrown(\Throwable $thrown): void { - if ($this->returnedState !== null || $this->outcome !== null) { + if ($this->returnedState !== null || $this->outcome instanceof \Rasuvaeff\Understudy\Outcome) { return; } diff --git a/src/Outcome.php b/src/Outcome.php index 0aed476..554a82a 100644 --- a/src/Outcome.php +++ b/src/Outcome.php @@ -53,7 +53,7 @@ public function didThrow(): bool public function returned(string $method): mixed { if (!$this->returned) { - \assert($this->thrown !== null); + \assert($this->thrown instanceof \Throwable); throw OutcomeUnavailable::threwInstead($method, $this->thrown); } diff --git a/src/Runtime/DoubleState.php b/src/Runtime/DoubleState.php index fd734c8..4b5be1a 100644 --- a/src/Runtime/DoubleState.php +++ b/src/Runtime/DoubleState.php @@ -422,7 +422,7 @@ public function declaredExpectations(): array */ public function settle(): void { - $remaining = static fn(Expectation $expectation): bool => $expectation->cardinality() === null; + $remaining = static fn(Expectation $expectation): bool => !$expectation->cardinality() instanceof \Rasuvaeff\Understudy\Cardinality; $this->expectations = array_values(array_filter($this->expectations, $remaining)); $this->matchingExpectations = array_values(array_filter($this->matchingExpectations, $remaining)); diff --git a/src/Runtime/Runtime.php b/src/Runtime/Runtime.php index f58cdaa..9e9117a 100644 --- a/src/Runtime/Runtime.php +++ b/src/Runtime/Runtime.php @@ -168,7 +168,7 @@ public static function popScope(): void { $fiber = \Fiber::getCurrent(); - if ($fiber === null) { + if (!$fiber instanceof \Fiber) { $context = array_pop(self::$main); if ($context instanceof RuntimeContext) { @@ -197,7 +197,7 @@ private static function stack(): array { $fiber = \Fiber::getCurrent(); - if ($fiber === null) { + if (!$fiber instanceof \Fiber) { return self::$main; } @@ -219,7 +219,7 @@ private static function push(RuntimeContext $context): void { $fiber = \Fiber::getCurrent(); - if ($fiber === null) { + if (!$fiber instanceof \Fiber) { self::$main[] = $context; return; @@ -267,7 +267,7 @@ private static function unremember(RuntimeContext $context): void public static function liveContexts(): array { $current = self::currentIfAny(); - $contexts = $current === null ? [] : [$current]; + $contexts = $current instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext ? [$current] : []; foreach (self::$live as $context) { if ($context !== $current) { @@ -299,7 +299,7 @@ public static function adoptClone(object $clone): void { $blueprint = DoubleFactory::blueprintOfGenerated($clone::class); - if ($blueprint === null) { + if (!$blueprint instanceof \Rasuvaeff\Understudy\Codegen\Blueprint) { // Only a generated class reaches this method, and every one of them // is registered when it is compiled. return; @@ -453,13 +453,13 @@ public static function forget(object $double): void // The facade has already answered for a stranger, a retired double and // a foreign context through `stateOf()`; what reaches here is owned. - \assert($owner !== null && $owner->stateOf($double) !== null); + \assert($owner instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext && $owner->stateOf($double) instanceof \Rasuvaeff\Understudy\Runtime\DoubleState); $owner->forget($double); self::owners()->offsetUnset($double); self::forgotten()->offsetSet($double, value: true); - if (self::$retiredOnPurpose === null) { + if (!self::$retiredOnPurpose instanceof \WeakMap) { /** @var \WeakMap $retired */ $retired = new \WeakMap(); self::$retiredOnPurpose = $retired; @@ -473,7 +473,7 @@ public static function forget(object $double): void */ private static function fibers(): \WeakMap { - if (self::$fibers === null) { + if (!self::$fibers instanceof \WeakMap) { /** @var \WeakMap<\Fiber, list> $fibers */ $fibers = new \WeakMap(); self::$fibers = $fibers; @@ -487,7 +487,7 @@ private static function fibers(): \WeakMap */ private static function owners(): \WeakMap { - if (self::$owners === null) { + if (!self::$owners instanceof \WeakMap) { /** @var \WeakMap $owners */ $owners = new \WeakMap(); self::$owners = $owners; @@ -501,7 +501,7 @@ private static function owners(): \WeakMap */ private static function droppedByScope(): \WeakMap { - if (self::$droppedByScope === null) { + if (!self::$droppedByScope instanceof \WeakMap) { /** @var \WeakMap $dropped */ $dropped = new \WeakMap(); self::$droppedByScope = $dropped; @@ -515,7 +515,7 @@ private static function droppedByScope(): \WeakMap */ private static function forgotten(): \WeakMap { - if (self::$forgotten === null) { + if (!self::$forgotten instanceof \WeakMap) { /** @var \WeakMap $forgotten */ $forgotten = new \WeakMap(); self::$forgotten = $forgotten; @@ -533,7 +533,7 @@ public static function isOwnedByCurrentContext(object $double): bool { $owner = self::ownerOf($double); - return $owner !== null && $owner === self::current(); + return $owner instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext && $owner === self::current(); } /** @@ -586,12 +586,12 @@ public static function dispatch(object $double, string $method, array $args): mi $context = $current; $state = $current->stateOf($double); - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { $context = self::ownerOf($double) ?? $current; $state = $context->stateOf($double); } - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { // Returning null here would violate the declared return type of // any non-nullable method, so say what actually happened. The // message differs for a double retired through `Understudy::forget()`: @@ -686,7 +686,7 @@ private static function answer( $verdict = SequenceVerdict::NotWatched; $sequence = $context->armed; - if ($sequence !== null) { + if ($sequence instanceof \Rasuvaeff\Understudy\Runtime\ArmedSequence) { $verdict = $sequence->offer($double, $invocation); if ($verdict === SequenceVerdict::OutOfTurn) { @@ -744,7 +744,7 @@ private static function answer( self::$inlineFloor = $floor; } - if ($signature !== null && $signature->returnsNever) { + if ($signature instanceof \Rasuvaeff\Understudy\Codegen\MethodSignature && $signature->returnsNever) { // The expectation returned instead of throwing; returning from // a `: never` method is a TypeError by language rule, so name // the real mistake rather than leaking that. @@ -775,7 +775,7 @@ private static function answer( return self::forward($state, $double, $method, $args); } - if ($signature !== null && $signature->returnsNever) { + if ($signature instanceof \Rasuvaeff\Understudy\Codegen\MethodSignature && $signature->returnsNever) { // Which mistake it is depends on whether anything was configured: // "you never said what this throws" reads very differently from // "nothing expected this call at all". @@ -788,9 +788,7 @@ private static function answer( // configured. Anything else is indistinguishable from a step arriving // out of turn — the protocol cannot tell "not part of this" from "you // got the order wrong" unless the test says which it is. - if (!$matched && $verdict === SequenceVerdict::NotAStep) { - \assert($sequence !== null); - + if ($sequence instanceof ArmedSequence && !$matched && $verdict === SequenceVerdict::NotAStep) { throw VerificationFailed::of([self::unconfiguredUnderProtocol($state, $sequence, $invocation, $double)]); } @@ -975,12 +973,12 @@ private static function propertyState(object $double, string $property): array $state = $current->stateOf($double); $context = $current; - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { $context = self::ownerOf($double) ?? $current; $state = $context->stateOf($double); } - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { throw ForgottenDouble::propertyAfterReset($property); } @@ -1014,7 +1012,7 @@ public static function referenceSlot(object $double, string $method, array $args // and the slot would keep the mode's own value instead of the // configured one. A recording phase is the exception — the sentinel // is what it came for. - if ($state !== null && !self::current()->isRecording()) { + if ($state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState && !self::current()->isRecording()) { self::materializeOmittedArguments($state->blueprint->method($method), $method, $args); } @@ -1036,7 +1034,7 @@ public static function referenceSlot(object $double, string $method, array $args $context = self::ownerOf($double) ?? self::current(); $state = $context->stateOf($double); - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { throw ForgottenDouble::afterReset($method); } @@ -1064,7 +1062,7 @@ public static function callOriginal(object $double, string $method, array $args) $context = self::ownerOf($double) ?? self::current(); $state = $context->stateOf($double); - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { throw ForgottenDouble::afterReset($method); } @@ -1139,7 +1137,7 @@ private static function runInline(DoubleState $state, object $double, string $me return $value; } - if ($value instanceof $double && self::ownerOf($value) === null) { + if ($value instanceof $double && !self::ownerOf($value) instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext) { throw OriginalReturnTypeViolation::foreignSelf($state->label(), $method); } @@ -1446,7 +1444,7 @@ private static function materializeOmittedArguments(?MethodSignature $signature, continue; } - if ($signature === null || !$signature->isOptional($position)) { + if (!$signature instanceof \Rasuvaeff\Understudy\Codegen\MethodSignature || !$signature->isOptional($position)) { throw new \ArgumentCountError(sprintf( 'Too few arguments to function %s(), argument #%d not passed', $method, @@ -1484,7 +1482,7 @@ public static function reset(): void { $fiber = \Fiber::getCurrent(); - if ($fiber === null) { + if (!$fiber instanceof \Fiber) { $stack = self::$main; } else { $fibers = self::fibers(); @@ -1509,7 +1507,7 @@ public static function reset(): void // plain array because the offset is a variable. /** @var list $stack */ - if ($fiber === null) { + if (!$fiber instanceof \Fiber) { self::$main = $stack; return; @@ -1574,7 +1572,7 @@ private static function retire(RuntimeContext $context, bool $byScope = false): $captor->discard(); } - if (self::$owners === null) { + if (!self::$owners instanceof \WeakMap) { return; } diff --git a/src/Runtime/RuntimeContext.php b/src/Runtime/RuntimeContext.php index 8b6ca55..178c790 100644 --- a/src/Runtime/RuntimeContext.php +++ b/src/Runtime/RuntimeContext.php @@ -191,7 +191,7 @@ public function allDoubles(): array public function rememberCaptor(Captor $captor): void { - if ($this->captors === null) { + if (!$this->captors instanceof \SplObjectStorage) { /** @var \SplObjectStorage $captors */ $captors = new \SplObjectStorage(); $this->captors = $captors; @@ -207,7 +207,7 @@ public function rememberCaptor(Captor $captor): void */ public function captors(): array { - if ($this->captors === null) { + if (!$this->captors instanceof \SplObjectStorage) { return []; } diff --git a/src/Understudy.php b/src/Understudy.php index afb0d00..f923b82 100644 --- a/src/Understudy.php +++ b/src/Understudy.php @@ -169,9 +169,9 @@ private static function returnContract(DoubleState $state, string $method): ?Ret { $signature = $state->blueprint->method($method); - return $signature === null - ? null - : new ReturnContract($state->label(), $method, $signature, $state->blueprint->contracts[0]); + return $signature instanceof \Rasuvaeff\Understudy\Codegen\MethodSignature + ? new ReturnContract($state->label(), $method, $signature, $state->blueprint->contracts[0]) + : null; } /** @@ -260,7 +260,7 @@ private static function failuresIn(RuntimeContext $context, bool $strictStubs): $failure = self::checkExpectation($state, $expectation, $strictStubs); - if ($failure !== null) { + if ($failure instanceof \Rasuvaeff\Understudy\VerificationFailure) { $contextFailures[] = $failure; } } @@ -276,7 +276,7 @@ private static function failuresIn(RuntimeContext $context, bool $strictStubs): $outOfOrder = self::orderingFailure($ordered); - if ($outOfOrder !== null) { + if ($outOfOrder instanceof \Rasuvaeff\Understudy\VerificationFailure) { $failures[] = $outOfOrder; } @@ -286,13 +286,13 @@ private static function failuresIn(RuntimeContext $context, bool $strictStubs): // would pass in silence. Whether one is armed is the check; a // complete protocol is a check that passed, an unfinished one the // failure below. - if ($context->armed !== null) { + if ($context->armed instanceof \Rasuvaeff\Understudy\Runtime\ArmedSequence) { $checks++; } $unfinished = self::checkArmedSequence($context); - if ($unfinished !== null) { + if ($unfinished instanceof \Rasuvaeff\Understudy\VerificationFailure) { $failures[] = $unfinished; } @@ -315,7 +315,7 @@ private static function orderedExpectations(?DoubleState $only = null, ?RuntimeC $ordered = []; foreach (($context ?? Runtime::current())->allStates() as $state) { - if ($only !== null && $state !== $only) { + if ($only instanceof \Rasuvaeff\Understudy\Runtime\DoubleState && $state !== $only) { continue; } @@ -391,12 +391,12 @@ private static function checkArmedSequence(RuntimeContext $context): ?Verificati { $sequence = $context->armed; - if ($sequence === null || $sequence->isComplete()) { + if (!$sequence instanceof \Rasuvaeff\Understudy\Runtime\ArmedSequence || $sequence->isComplete()) { return null; } $pending = $sequence->pending(); - \assert($pending !== null); + \assert($pending instanceof \Rasuvaeff\Understudy\Expectation\Expectation); return ArgumentFormatter::scope(static fn(): VerificationFailure => new VerificationFailure( kind: FailureKind::OutOfSequence, @@ -421,7 +421,7 @@ private static function checkExpectation(DoubleState $state, Expectation $expect $cardinality = $expectation->cardinality(); $count = $expectation->matchCount(); - if ($cardinality === null) { + if (!$cardinality instanceof \Rasuvaeff\Understudy\Cardinality) { // A plain stub is permission, not a claim — unless strict stubs // turn "configured but never used" into a failure of its own. return $strictStubs && $count === 0 @@ -708,7 +708,7 @@ public static function forwarding(object $double, ?object $real = null): void if ($real !== null) { // A double delegating to a double — itself included — sends every // call back into the dispatcher it came from. - if (Runtime::ownerOf($real) !== null) { + if (Runtime::ownerOf($real) instanceof \Rasuvaeff\Understudy\Runtime\RuntimeContext) { throw ForwardingTargetMismatch::understudyTarget($state->label()); } @@ -1076,14 +1076,14 @@ public static function allVerified(object $double): void foreach ($state->expectations() as $expectation) { $failure = self::checkExpectation($state, $expectation, strictStubs: false); - if ($failure !== null) { + if ($failure instanceof \Rasuvaeff\Understudy\VerificationFailure) { $failures[] = $failure; } } $outOfOrder = self::orderingFailure(self::orderedExpectations($state)); - if ($outOfOrder !== null) { + if ($outOfOrder instanceof \Rasuvaeff\Understudy\VerificationFailure) { $failures[] = $outOfOrder; } @@ -1159,7 +1159,7 @@ public static function expectSequence(callable ...$calls): void // Only a concurrent one is refused. A protocol that ran to completion // has nothing left to disagree about, and a two-phase test must be // able to describe its second phase. - if ($armed !== null && !$armed->isComplete()) { + if ($armed instanceof \Rasuvaeff\Understudy\Runtime\ArmedSequence && !$armed->isComplete()) { throw InvalidCallSpecification::protocolAlreadyArmed($armed->position(), $armed->length()); } @@ -1200,7 +1200,7 @@ public static function verifySequence(callable ...$calls): void $mismatch = self::firstSequenceMismatch($probes, $log); - if ($mismatch !== null) { + if ($mismatch instanceof \Rasuvaeff\Understudy\VerificationFailure) { throw VerificationFailed::of([$mismatch]); } @@ -1548,7 +1548,7 @@ private static function stateOf(object $double, string $facade): DoubleState { $state = Runtime::stateOf($double); - if ($state === null) { + if (!$state instanceof \Rasuvaeff\Understudy\Runtime\DoubleState) { if (Runtime::isRetiredOnPurpose($double)) { throw ForgottenDouble::retired(); } diff --git a/src/WhenBuilder.php b/src/WhenBuilder.php index be4baea..8a2f9a3 100644 --- a/src/WhenBuilder.php +++ b/src/WhenBuilder.php @@ -71,7 +71,7 @@ public function returns(mixed ...$values): static throw InvalidSpecificationArgument::noReturnValues(); } - if ($this->contract !== null) { + if ($this->contract instanceof \Rasuvaeff\Understudy\Expectation\ReturnContract) { // `returns(null)` on a void method is the idiom for "answer // nothing", and PHP itself reads a void method as answering null; // only a value that would be silently dropped is refused. diff --git a/src/Wiring/Wire.php b/src/Wiring/Wire.php index c60a019..a9dc94b 100644 --- a/src/Wiring/Wire.php +++ b/src/Wiring/Wire.php @@ -305,7 +305,7 @@ private static function matchesType(\ReflectionType $type, mixed $value): bool private static function typeName(?\ReflectionType $type): string { - return $type === null ? 'mixed' : (string) $type; + return $type instanceof \ReflectionType ? (string) $type : 'mixed'; } /** diff --git a/tests/Support/DispatchFindCommand.php b/tests/Support/DispatchFindCommand.php index 57f9586..ea4887b 100644 --- a/tests/Support/DispatchFindCommand.php +++ b/tests/Support/DispatchFindCommand.php @@ -47,7 +47,7 @@ public function run(mixed $model, mixed $system): array $answering = $model->answerFor($this->id); - if ($answering === null) { + if (!$answering instanceof \Rasuvaeff\Understudy\Tests\Support\EngineSpec) { ++$system->unmatchedDefaults; } elseif ($answering->hasAction()) { ++$system->stubAnswers; @@ -74,7 +74,7 @@ public function postCondition(mixed $model, mixed $result): bool } $answering = $model->answerFor($this->id); - $expectedTitle = $answering !== null && $answering->hasAction() ? $answering->answerTitle : null; + $expectedTitle = $answering instanceof \Rasuvaeff\Understudy\Tests\Support\EngineSpec && $answering->hasAction() ? $answering->answerTitle : null; return $title === $expectedTitle; }