The expression return $request->wantsJs...son() : $this->toHtml() returns the type Illuminate\View\View|array which is incompatible with the return type mandated by Illuminate\Contracts\Sup...sponsable::toResponse() of Symfony\Component\HttpFoundation\Response.
In the issue above, the returned value is violating the contract defined by the
mentioned interface.
Let's take a look at an example:
interfaceHasName{/** @return string */publicfunctiongetName();}className{public$name;}classUserimplementsHasName{/** @return string|Name */publicfunctiongetName(){returnnewName('foo');// This is a violation of the ``HasName`` interface// which only allows a string value to be returned.}}
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: