Answer the question
In order to leave comments, you need to log in
Why did phpstorm stop checking the return type from phpdoc when implementing an interface that returns an array?
Good afternoon. Problem Example:
class Entity
{
}
interface IFace
{
/**
* @return Entity[]
*/
public function get(): array;
}
class DTO
{
}
interface Repo
{
/**
* @return DTO[]
*/
public function get(): array;
}
class Impl implements IFace
{
private Repo $repo;
public function __construct(Repo $repo)
{
$this->repo = $repo;
}
/**
* @return Entity[]
*/
public function get(): array
{
return $this->repo->get();
}
}
class Entity
{
}
interface IFace
{
/**
* @return Entity[]
*/
public function get();
}
class DTO
{
}
interface Repo
{
/**
* @return DTO[]
*/
public function get(): array;
}
class Impl implements IFace
{
private Repo $repo;
public function __construct(Repo $repo)
{
$this->repo = $repo;
}
/**
* @return Entity[]
*/
public function get()
{
return $this->repo->get();
}
}
Answer the question
In order to leave comments, you need to log in
It will probably only be possible to solve it by sending feedback to the developers. In general, it is clear how it happened. Changed language level typing priority over docblock types.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question