The method count does only exist in Illuminate\Support\Collection, but not in Realshadow\Redtube\Entities\Videos.
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.}
The expression $this->items; of type Illuminate\Support\Colle...Redtube\Entities\Videos adds the type Realshadow\Redtube\Entities\Videos to the return on line 107 which is incompatible with the return type documented by Realshadow\Redtube\Entities\Paginator::items of type Illuminate\Support\Collection.
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: