Closed laurentmuller closed 1 month ago
/cc @xificurk Is it possible you broke this with your stubs? Thanks.
I does not use any custom stubs.
You use phpstan-doctrine which includes a lot of them.
Yes. But before commit #620, my code working without error.
Hm, I might be missing some phpstan internals knowledge, but (to my surprise), it looks like the stub phpdoc from ReadableCollection::map takes precedence not only over original ReadableCollection::map phpdoc, but even original Collection::map.
I'm running into the same issue, using ::filter()
:
/**
* @return Collection<int, TopicItem>
*/
public function getItems(): Collection
{
$livestreamStartLimiter = new \DateTimeImmutable(self::LIVESTREAM_START_LIMITER);
return $this->items->filter(function (TopicItem $topicItem) use ($livestreamStartLimiter): bool {
// simplified code here
return true;
});
}
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line src/TopicBundle/Entity/Topic.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
280 Method App\TopicBundle\Entity\Topic::getItems() should return Doctrine\Common\Collections\Collection<int, App\TopicBundle\Entity\TopicItem> but returns Doctrine\Common\Collections\ReadableCollection<int,
App\TopicBundle\Entity\TopicItem>.
✏️ src/TopicBundle/Entity/Topic.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This happens while upgrading phpstan/phpstan-doctrine
from 1.5.3 => 1.5.4.
It'seem that we have to update the *.stub
files in Collections
folder to reflect the php doc.
What happens if we remove all this collection stub files ?
I'm running into the same issue, using
::filter()
:[...]
This happens while upgrading
phpstan/phpstan-doctrine
from 1.5.3 => 1.5.4.
Exact same situation here.
I just downloaded the last version (1.5.5) and it is work as expected !
Great job !!!!
Thank you, 1.5.5 works for me, too!
After update PHPStan to version 1.5.4, the map function of collection does not work anymore.
Example:
The follwing error is raised:
Maybe, the
Collection
andArrayCollection
stubs must be also updated.