The method exists does only exist in Illuminate\Contracts\View\Factory, but not in Illuminate\View\View.
It seems like the method you are trying to call exists only in some of the
possible types.
Let’s take a look at an example:
classA{publicfunctionfoo(){}}classBextendsA{publicfunctionbar(){}}/** * @param A|B $x */functionsomeFunction($x){$x->foo();// This call is fine as the method exists in A and B.$x->bar();// This method only exists in B and might cause an error.}
It seems like view($classOrView) targeting view() can also be of type object<Illuminate\Contracts\View\Factory>; however, Spatie\BladeX\BladeViewComponent::__construct() does only seem to accept object<Illuminate\View\View>, maybe add an additional type check?
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: