I was thinking about how to annotate types in PhpStorm. I believe PhpStorm is using Psalm to resolve types, but I can’t find how to annotate type to get suggestions here:
$row
in my app will always be Collection
object and I want to have it marked somewhere here with annotations.
Does anyone have an idea how to accomplish that?
/** * @param Collection $rows */ public function collection(Collection $rows) { foreach ($rows as $row) { dump($row->); // $row is also Collection object } }
Advertisement
Answer
you can mark var type like this:
/** @var $row Collection **/ dump($row->);