I was just trying to apply filtering on a collection with InstanceOfX but it failed while the DQL version works fine. I figured out that the isStatisfiedBy() method does not take context into account in any way but the DQL does.
Would this be a proper fix?
public function isSatisfiedBy($candidate, ?string $context = null): bool
{
if (null !== $this->context) {
$candidate = ArgumentToOperandConverter::toField($this->context)
->execute($candidate, $context);
}
return $candidate instanceof $this->value;
}