The return type of return $this->edges; (Overblog\GraphQLBundle\R...onnection\Output\Edge[]) is incompatible with the return type declared by the interface Overblog\GraphQLBundle\R...tionInterface::getEdges of type Overblog\GraphQLBundle\Relay\Connection\iterable.
If you return a value from a function or method, it should be a sub-type of the
type that is given by the parent type f.e. an interface, or abstract method.
This is more formally defined by the
Lizkov substitution principle,
and guarantees that classes that depend on the parent type can use any instance
of a child type interchangably. This principle also belongs to the
SOLID principles
for object oriented design.
Our function my_function expects a Post object, and outputs the author
of the post. The base class Post returns a simple string and outputting a
simple string will work just fine. However, the child class BlogPost which
is a sub-type of Post instead decided to return an object, and is
therefore violating the SOLID principles. If a BlogPost were passed to
my_function, PHP would not complain, but ultimately fail when executing the
strtoupper call in its body.
It seems like $edges of type object<Overblog\GraphQLB...ay\Connection\iterable> is incompatible with the declared type array<integer,object<Ove...onnection\Output\Edge>> of property $edges.
Our type inference engine has found an assignment to a property that is incompatible
with the declared type of that property.
Either this assignment is in error or the assigned type should be added
to the documentation/type hint for that property..
Loading history...
40
1
}
41
42
/**
43
* {@inheritdoc}
44
*/
45
41
public function getPageInfo(): ? PageInfo
46
{
47
41
return $this->pageInfo;
48
}
49
50
/**
51
* {@inheritdoc}
52
*/
53
public function setPageInfo(PageInfo $pageInfo): void
54
{
55
$this->pageInfo = $pageInfo;
56
}
57
58
/**
59
* {@inheritdoc}
60
*/
61
29
public function getTotalCount(): int
62
{
63
29
return $this->totalCount;
64
}
65
66
/**
67
* {@inheritdoc}
68
*/
69
4
public function setTotalCount(int $totalCount): void
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.