In this branch, the function will implicitly return null which is incompatible with the type-hinted return SignpostMarv\DaftObject\SuitableForRepositoryType. Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type.
Let?s take a look at an example:
interfaceReturnsInt{publicfunctionreturnsIntHinted():int;}classMyClassimplementsReturnsInt{publicfunctionreturnsIntHinted():int{if(foo()){return123;}// here: null is implicitly returned}}
Loading history...
34
24
35
24
protected function ObtainLastLeafInTree() : DaftNestedWriteableObject
36
24
{
37
/**
38
24
* @var \ParagonIE\EasyDB\EasyDB
39
24
*/
40
24
$db = $this->db;
41
24
42
24
/**
43
* @psalm-var class-string<T>
44
*/
45
24
$type = $this->type;
46
47
24
$sth = $db->prepare(
48
'SELECT ' .
49
24
implode(',', array_map(
50
24
[$db, 'escapeIdentifier'],
51
$type::DaftObjectIdProperties()
52
)) .
53
24
' FROM ' .
54
$this->DaftObjectDatabaseTable() .
55
' ORDER BY ' .
56
$db->escapeIdentifier('intNestedLeft') .
57
' DESC LIMIT 1'
58
);
59
60
$sth->execute();
61
62
$res = $sth->fetch(PDO::FETCH_ASSOC);
63
64
if (1 === count($res) && ! is_a($type, DefinesOwnArrayIdInterface::class, true)) {
The expression return $this->RecallDaftObjectOrThrow($res) returns the type SignpostMarv\DaftObject\SuitableForRepositoryType which includes types incompatible with the type-hinted return SignpostMarv\DaftObject\DaftNestedWriteableObject.
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.