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
}
41
42
/**
43
* {@inheritdoc}
44
*/
45
public function getPageInfo(): ? PageInfo
46
{
47
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
public function getTotalCount(): int
62
{
63
return $this->totalCount;
64
}
65
66
/**
67
* {@inheritdoc}
68
*/
69
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_functionexpects aPostobject, and outputs the author of the post. The base classPostreturns a simple string and outputting a simple string will work just fine. However, the child classBlogPostwhich is a sub-type ofPostinstead decided to return anobject, and is therefore violating the SOLID principles. If aBlogPostwere passed tomy_function, PHP would not complain, but ultimately fail when executing thestrtouppercall in its body.