The expression view($template, compact('page')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 37 which is incompatible with the return type documented by Modules\Page\Http\Contro...s\PublicController::uri of type Illuminate\View\View.
The expression view($template, compact('page')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 51 which is incompatible with the return type documented by Modules\Page\Http\Contro...licController::homepage of type Illuminate\View\View.
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.}