The method shouldReceive does only exist in Mockery\Mock, but not in Nip\Database\Connections\Connection.
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 method setAdapter does only exist in Nip\Database\Connections\Connection, but not in Mockery\Mock.
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 $database can also be of type object<Mockery\Mock>; however, Nip\Records\Traits\HasDa...seRecordsTrait::setDB() does only seem to accept object<Nip\Database\Connections\Connection>, maybe add an additional type check?
If a method or function can return multiple different values and unless you are
sure that you only can receive a single value in this context, we recommend
to add an additional type check:
/** * @return array|string */functionreturnsDifferentValues($x){if($x){return'foo';}returnarray();}$x=returnsDifferentValues($y);if(is_array($x)){// $x is an array.}
If this a common case that PHP Analyzer should handle natively, please let us
know by opening an issue.
Loading history...
34
ModelLocator::set('emails', $emailsTable);
35
36
$command = new EmailsCleanupRecords();
37
$command->handle();
38
39
self::assertInstanceOf(Delete::class, $query);
40
self::assertSame(
41
'DELETE FROM `emails` WHERE `type` = \'donation\' AND `date_sent` <= DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY)',
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: